From e410c28c1d45e70d2fbafa146c9ba65685eab2be Mon Sep 17 00:00:00 2001 From: Carlos E Silva Date: Fri, 10 Nov 2017 08:32:02 -0500 Subject: [PATCH] Run recently merged pull request code through Prettier Enable console.log in eslint --- .eslintrc.json | 7 +++-- index.js | 77 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6f67564..954d644 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,6 @@ { - "extends": "airbnb-base" -} \ No newline at end of file + "extends": "airbnb-base", + "rules": { + "no-console": "off" + } +} diff --git a/index.js b/index.js index 4c72633..d874c77 100644 --- a/index.js +++ b/index.js @@ -8,13 +8,46 @@ const partNumbers = require('./partNumbers.json'); // Define command line args accepted. const optionDefinitions = [ - { name: 'carrier', type: String, defaultValue: 'TMOBILE', description: "Define which carrier to search for. Accepted options are: 'ATT', 'SPRING', 'TMOBILE', 'VERIZON'."}, - { name: 'model', type: String, defaultValue: 'x', description: "Define which model iPhone to search for. 'x' is the only option currently available."}, - { name: 'color', type: String, defaultValue: 'gray', description: "Define which color iPhone to search for. Accepted options are: 'silver', 'gray'."}, - { name: 'storage', type: String, defaultValue: '256', description: "Define which storage size to search for. Accepted options are: '64', '256'."}, - { name: 'zip', type: String, defaultOption: true, description: "Define the area to search in by zip code. This option is required."}, - { name: 'delay', type: Number, defaultValue: 30, description: "Define the number of seconds between requests."}, - { name: 'help', type: Boolean, description: "Display this help screen."}, + { + name: 'carrier', + type: String, + defaultValue: 'TMOBILE', + description: + "Define which carrier to search for. Accepted options are: 'ATT', 'SPRING', 'TMOBILE', 'VERIZON'.", + }, + { + name: 'model', + type: String, + defaultValue: 'x', + description: + "Define which model iPhone to search for. 'x' is the only option currently available.", + }, + { + name: 'color', + type: String, + defaultValue: 'gray', + description: + "Define which color iPhone to search for. Accepted options are: 'silver', 'gray'.", + }, + { + name: 'storage', + type: String, + defaultValue: '256', + description: "Define which storage size to search for. Accepted options are: '64', '256'.", + }, + { + name: 'zip', + type: String, + defaultOption: true, + description: 'Define the area to search in by zip code. This option is required.', + }, + { + name: 'delay', + type: Number, + defaultValue: 30, + description: 'Define the number of seconds between requests.', + }, + { name: 'help', type: Boolean, description: 'Display this help screen.' }, ]; // Parse command line args. @@ -24,34 +57,36 @@ const options = commandLineArgs(optionDefinitions); const usageDefinition = [ { header: 'iPhone X Availability Node CLI', - content: "The app continously makes requests to Apple's availability api. When it finds some new stock near you, it displays the stores' name and distance from your zipcode then exits the program." + content: + "The app continously makes requests to Apple's availability api. When it finds some new stock near you, it displays the stores' name and distance from your zipcode then exits the program.", }, { header: 'Synopsis', content: [ - { + { desc: 'Default arguments.', - example: '$ node index.js [bold]{--carrier} TMOBILE [bold]{--model} x [bold]{--color} gray [bold]{--storage} 256 [bold]{--delay} 30' + example: + '$ node index.js [bold]{--carrier} TMOBILE [bold]{--model} x [bold]{--color} gray [bold]{--storage} 256 [bold]{--delay} 30', }, - { + { desc: 'Simple example', - example: '$ node index.js [bold]{--zip} 10001 [bold]{--color} silver' + example: '$ node index.js [bold]{--zip} 10001 [bold]{--color} silver', }, - { + { desc: 'Help screen.', - example: '$ node index.js [bold]{--help}' + example: '$ node index.js [bold]{--help}', }, - ] + ], }, { - header: "Options", - optionList: optionDefinitions - } -] + header: 'Options', + optionList: optionDefinitions, + }, +]; -// if --help is present or --zip wasn't defined, +// if --help is present or --zip wasn't defined, // then display the help screen and exit the program. -if (options['help'] || options['zip'] === undefined) { +if (options.help || options.zip === undefined) { console.log(getUsage(usageDefinition)); process.exit(); }