check-installed 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,32 +75,32 @@ They are typed to accept the entire `options` object, but only use options they
75
75
  - `string`: `--option-name=value`
76
76
  - Options for `checkEngines` and `checkModules` are the same as CLI options but `camelCased`
77
77
 
78
- ### `--help`
78
+ #### `--help`
79
79
  Show help (skips check)
80
80
 
81
81
  *Type: `boolean`, Default: `false`*
82
82
 
83
- ### `--skip-engines`
83
+ #### `--skip-engines`
84
84
  Skip checking engines
85
85
 
86
86
  *Type: `boolean`, Default: `false`*
87
87
 
88
- ### `--skip-modules`
88
+ #### `--skip-modules`
89
89
  Skip checking node modules
90
90
 
91
91
  *Type: `boolean`, Default: `false`*
92
92
 
93
- ### `--show-success`
93
+ #### `--show-success`
94
94
  Show success message on successful checks
95
95
 
96
96
  *Type: `boolean`, Default: `false`*
97
97
 
98
- ### `--show-engines`
98
+ #### `--show-engines`
99
99
  Show installed engines on successful check
100
100
 
101
101
  *Type: `boolean`, Default: `false`*
102
102
 
103
- ### `--show-modules`
103
+ #### `--show-modules`
104
104
  Show installed node modules on successful check
105
105
 
106
106
  *Type: `boolean`, Default: `false`*
@@ -73,6 +73,10 @@ async function checkEngines (json = {}, options) {
73
73
  console.log(`${name}: ${installed} (${version})`)
74
74
  }
75
75
  }
76
+
77
+ if (showSuccess || showEngines) {
78
+ console.log('')
79
+ }
76
80
  }
77
81
 
78
82
  module.exports = {
@@ -80,6 +80,10 @@ async function checkModules (json = {}, options) {
80
80
  console.log(`${name}: ${installed} (${aliased}${version})`)
81
81
  }
82
82
  }
83
+
84
+ if (showSuccess || showModules) {
85
+ console.log('')
86
+ }
83
87
  }
84
88
 
85
89
  module.exports = {
package/lib/cli.js CHANGED
@@ -1,45 +1,9 @@
1
1
  const { resolve } = require('path')
2
- const { HELP, OPTIONS } = require('./constants')
2
+ const { HELP } = require('./constants')
3
+ const { getOptions } = require('./getOptions')
3
4
  const { checkEngines } = require('./checkEngines')
4
5
  const { checkModules } = require('./checkModules')
5
6
 
6
- /**
7
- * Get options from CLI arguments
8
- * @param {string[]} args - CLI arguments
9
- * @returns {typeof OPTIONS} - Options for the CLI with defaults
10
- */
11
- function getOptions (args) {
12
- const options = {}
13
-
14
- for (const arg of args) {
15
- if (arg.startsWith('--')) {
16
- const [key, value] = arg.slice(2).split('=')
17
- const keyCamelCase = key.replace(/-([a-z])/g, (_, c) => c.toUpperCase())
18
- const option = OPTIONS[keyCamelCase]
19
-
20
- // Only set if the option is defined in `OPTIONS`
21
- if (option !== undefined) {
22
- let newValue
23
-
24
- // If boolean, `true` only if no value or value is "true"
25
- // Otherwise, only if value provided
26
- if (typeof option === 'boolean') {
27
- newValue = value == null ? true : value === 'true'
28
- } else if (value != null) {
29
- newValue = value
30
- }
31
-
32
- // Set only if valid and not already default
33
- if (newValue !== undefined && newValue !== option) {
34
- options[keyCamelCase] = newValue
35
- }
36
- }
37
- }
38
- }
39
-
40
- return options
41
- }
42
-
43
7
  /**
44
8
  * check-installed CLI entry point
45
9
  * @param {string[]} argv - CLI arguments
@@ -0,0 +1,42 @@
1
+ const { OPTIONS } = require('./constants')
2
+
3
+ /**
4
+ * Get check-installed options from CLI arguments
5
+ * @param {string[]} args - CLI arguments
6
+ * @returns {typeof OPTIONS} - Options for the CLI with defaults
7
+ */
8
+ function getOptions (args = []) {
9
+ const options = {}
10
+
11
+ for (const arg of args) {
12
+ if (arg.startsWith('--')) {
13
+ const [key, value] = arg.slice(2).split('=')
14
+ const keyCamelCase = key.replace(/-([a-z])/g, (_, c) => c.toUpperCase())
15
+ const option = OPTIONS[keyCamelCase]
16
+
17
+ // Only set if the option is defined in `OPTIONS`
18
+ if (option !== undefined) {
19
+ let newValue
20
+
21
+ // If boolean, `true` only if no value or value is "true"
22
+ // Otherwise, only if value provided
23
+ if (typeof option === 'boolean') {
24
+ newValue = value == null ? true : value === 'true'
25
+ } else if (value != null) {
26
+ newValue = value
27
+ }
28
+
29
+ // Set only if valid and not already default
30
+ if (newValue !== undefined && newValue !== option) {
31
+ options[keyCamelCase] = newValue
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ return options
38
+ }
39
+
40
+ module.exports = {
41
+ getOptions
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "check-installed",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Minimal Node package to check that dependencies are installed ✅",
5
5
  "author": "Phillip Lanclos <check-installed@flippidippi.com>",
6
6
  "license": "Unlicense",
@@ -32,7 +32,7 @@
32
32
  "npm": ">=6"
33
33
  },
34
34
  "scripts": {
35
- "check": "./bin/check-installed",
35
+ "check": "./bin/check-installed --show-engines",
36
36
  "lint": "standard",
37
37
  "lint:fix": "npm run lint -- --fix",
38
38
  "test": "npm run check && jest",