-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (26 loc) · 1010 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const nodeJsSampleModule = require('nodejs-sample-module');
const main = () => {
const logger = nodeJsSampleModule.Log.logger
const utils = nodeJsSampleModule.Utils;
logger.info('### START APPLICATION ###')
try {
const arguments = process.argv.slice(2); // removing node & path to index.js file
logger.info(`arguments: ${JSON.stringify(arguments)}`)
if (arguments.length === 0 || arguments.length !== 2) {
throw new Error('Input arguments array is empty or length different than required (2). Use two numbers - example: node index.js 1 2')
}
const a = arguments[0];
const b = arguments[1];
if (isNaN(a) || isNaN(b)) {
throw new Error('Input arguments are not numbers. Use numbers as input arguments!');
}
const parsedA = eval(a);
const parsedB = eval(b)
const result = utils.sum(parsedA,parsedB);
logger.info(`result: ${result}`)
} catch (error) {
logger.error(error);
}
logger.info('### END APPLICATION ###')
}
main();