Skip to content

Commit

Permalink
Platform segmentation added
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham-Kumar-2000 committed Apr 23, 2021
1 parent d716760 commit e4bffd4
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"jsxBracketSameLine": true,
"parser": "flow",
"semi": true,
"endOfLine":"auto"
"endOfLine":"auto",
"tabWidth":4
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"url": "https://github.com/Shubham-Kumar-2000/protocol-registry/issues"
},
"homepage": "https://github.com/Shubham-Kumar-2000/protocol-registry#readme",
"dependencies": {},
"dependencies": {
"winreg": "^1.2.4"
},
"devDependencies": {
"eslint": "^7.22.0",
"eslint-config-prettier": "^6.7.0",
Expand Down
8 changes: 8 additions & 0 deletions src/config/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const constants = {
platforms: {
windows: 'win32',
linux: 'linux',
macos: 'darwin'
}
};
module.exports = constants;
16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
'use strict';

console.log('hello world');
const constants = require('./config/constants');
const linux = require('./linux');
const macos = require('./macos');
const windows = require('./windows');

const getplatform = () => {
if (process.platform === constants.platforms.windows) return windows;
if (process.platform === constants.platforms.linux) return linux;
if (process.platform === constants.platforms.macos) return macos;
throw new Error('Unknown OS');
};

const platform = getplatform();

module.exports = platform;
5 changes: 5 additions & 0 deletions src/linux/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
hello: () => {
console.log('hello linux');
}
};
5 changes: 5 additions & 0 deletions src/macos/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
hello: () => {
console.log('hello macos');
}
};
5 changes: 5 additions & 0 deletions src/windows/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
hello: () => {
console.log('hello windows');
}
};

0 comments on commit e4bffd4

Please sign in to comment.