find-cli 0.0.3 → 1.4.4

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.
Files changed (68) hide show
  1. package/README.md +43 -5
  2. package/bin/abbreviations.js +10 -0
  3. package/bin/action/addRootDirectoryPath.js +31 -0
  4. package/bin/action/find.js +84 -0
  5. package/bin/action/help.js +40 -0
  6. package/bin/action/initialise.js +18 -0
  7. package/bin/action/listRootDirectoryPaths.js +18 -0
  8. package/bin/action/removeRootDirectoryPath.js +33 -0
  9. package/bin/action/version.js +15 -0
  10. package/bin/commands.js +19 -0
  11. package/bin/configuration/version_1_1.js +26 -0
  12. package/bin/configuration/version_1_2.js +48 -0
  13. package/bin/configuration/version_1_3.js +22 -0
  14. package/bin/configuration/version_1_4.js +58 -0
  15. package/bin/configuration.js +230 -0
  16. package/bin/constants.js +25 -0
  17. package/bin/converter/alternates.js +29 -0
  18. package/bin/converter/characterClass.js +45 -0
  19. package/bin/converter/default.js +19 -0
  20. package/bin/converter/directory.js +19 -0
  21. package/bin/converter/escapedCharacter.js +19 -0
  22. package/bin/converter/period.js +19 -0
  23. package/bin/converter/questionMark.js +19 -0
  24. package/bin/converter/repeatedDirectories.js +19 -0
  25. package/bin/converter/repeatedWildcard.js +19 -0
  26. package/bin/converter/singleDirectory.js +19 -0
  27. package/bin/converter/singleWildcard.js +19 -0
  28. package/bin/converter.js +48 -0
  29. package/bin/converters.js +29 -0
  30. package/bin/defaults.js +13 -0
  31. package/bin/descriptions.js +11 -0
  32. package/bin/find.js +55 -0
  33. package/bin/isIgnored/asynchronous.js +59 -0
  34. package/bin/isIgnored/synchronous.js +104 -0
  35. package/bin/line.js +181 -0
  36. package/bin/main.js +85 -0
  37. package/bin/messages.js +37 -0
  38. package/bin/occurrence.js +40 -0
  39. package/bin/operation/addRootDirectoryPath.js +16 -0
  40. package/bin/operation/find.js +201 -0
  41. package/bin/operation/listRootDirectoryPaths.js +34 -0
  42. package/bin/operation/prompt/addRootDirectoryPath.js +48 -0
  43. package/bin/operation/prompt/ignoreOrPermitPath.js +46 -0
  44. package/bin/operation/prompt/removeRootDirectoryPath.js +61 -0
  45. package/bin/operation/prompt/rule.js +50 -0
  46. package/bin/operation/readConfiguration.js +27 -0
  47. package/bin/operation/removeRootDirectoryPath.js +29 -0
  48. package/bin/operation/removeRootDirectoryPathByIndex.js +34 -0
  49. package/bin/operation/rule.js +32 -0
  50. package/bin/operation/updatePatRules.js +54 -0
  51. package/bin/operation/validateRootDirectoryPath.js +30 -0
  52. package/bin/options.js +13 -0
  53. package/bin/prepare.js +51 -0
  54. package/bin/rule/glob.js +170 -0
  55. package/bin/rule/regex.js +141 -0
  56. package/bin/rule/string.js +117 -0
  57. package/bin/types.js +11 -0
  58. package/bin/utilities/literal.js +19 -0
  59. package/bin/utilities/log.js +26 -0
  60. package/bin/utilities/operation.js +38 -0
  61. package/bin/utilities/path.js +58 -0
  62. package/bin/utilities/prompt.js +7 -0
  63. package/bin/utilities/rule.js +18 -0
  64. package/bin/utilities/string.js +36 -0
  65. package/bin/utilities/validate.js +56 -0
  66. package/bin/versions.js +15 -0
  67. package/find.js +18 -0
  68. package/package.json +5 -2
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+
3
+ const { fileSystemUtilities } = require("necessary");
4
+
5
+ const find = require("../find");
6
+
7
+ const { red, green } = require("../utilities/log"),
8
+ { synchronousIsFilePathIgnored, synchronousIsDirectoryPathIgnored } = require("../isIgnored/synchronous"),
9
+ { asynchronousIsFilePathIgnored, asynchronousIsDirectoryPathIgnored } = require("../isIgnored/asynchronous"),
10
+ { isDirectoryPathRootDirectoryPath, entryPathsFromEntryNamesAndDirectoryPath } = require("../utilities/path");
11
+
12
+ const { readDirectory, isEntryDirectory } = fileSystemUtilities;
13
+
14
+ function findOperation(proceed, abort, context) {
15
+ const { rootDirectoryPaths } = context,
16
+ entryPaths = [ ///
17
+ ...rootDirectoryPaths
18
+ ],
19
+ synchronous = findInEntries(entryPaths, (pathIgnored) => {
20
+ if (pathIgnored === null) {
21
+ abort();
22
+ }
23
+ }, context);
24
+
25
+ if (synchronous) {
26
+ proceed();
27
+ }
28
+ }
29
+
30
+ module.exports = findOperation;
31
+
32
+ function findInEntries(entryPaths, callback, context) {
33
+ let synchronous = true;
34
+
35
+ let entryNamesLength;
36
+
37
+ entryNamesLength = entryPaths.length;
38
+
39
+ while (entryNamesLength > 0) {
40
+ const entryPath = entryPaths.shift();
41
+
42
+ synchronous = findInEntry(entryPath, entryPaths, callback, context);
43
+
44
+ if (!synchronous) {
45
+ break;
46
+ }
47
+
48
+ entryNamesLength = entryPaths.length;
49
+ }
50
+
51
+ return synchronous;
52
+ }
53
+
54
+ function findInEntry(entryPath, entryPaths, callback, context) {
55
+ let synchronous;
56
+
57
+ const path = entryPath,
58
+ directory = isEntryDirectory(path);
59
+
60
+ if (directory) {
61
+ const directoryPath = entryPath; ///
62
+
63
+ synchronous = findInDirectory(directoryPath, (pathIgnored) => {
64
+ const synchronous = (pathIgnored !== null) ?
65
+ findInEntries(entryPaths, callback, context) :
66
+ true;
67
+
68
+ if (synchronous) {
69
+ callback(pathIgnored);
70
+ }
71
+ }, context);
72
+ } else {
73
+ const filePath = entryPath; ///
74
+
75
+ synchronous = findInFile(filePath, (pathIgnored) => {
76
+ const synchronous = (pathIgnored !== null) ?
77
+ findInEntries(entryPaths, callback, context) :
78
+ true;
79
+ if (synchronous) {
80
+ callback(pathIgnored);
81
+ }
82
+ }, context);
83
+ }
84
+
85
+ if (synchronous) {
86
+ synchronous = findInEntries(entryPaths, callback, context);
87
+ }
88
+
89
+ return synchronous;
90
+ }
91
+
92
+ function findInFile(filePath, callback, context) {
93
+ let synchronous;
94
+
95
+ const filePathIgnored = synchronousIsFilePathIgnored(filePath, context);
96
+
97
+ if (filePathIgnored !== null) {
98
+ synchronous = true;
99
+
100
+ const { quietly } = context;
101
+
102
+ if (!quietly) {
103
+ const { ruleString } = context;
104
+
105
+ let message = filePathIgnored ?
106
+ red(`Ignore ${filePath}`) :
107
+ green(`Permit ${filePath}`);
108
+
109
+ message = `${message} ${ruleString}`;
110
+
111
+ console.log(message);
112
+ }
113
+
114
+ if (!filePathIgnored) {
115
+ let { filesTotal } = context;
116
+
117
+ filesTotal++;
118
+
119
+ Object.assign(context, {
120
+ filesTotal
121
+ });
122
+
123
+ const { dryRun } = context;
124
+
125
+ if (!dryRun) {
126
+ find(filePath, context);
127
+ }
128
+ }
129
+ } else {
130
+ synchronous = false;
131
+
132
+ asynchronousIsFilePathIgnored(filePath, context, (pathIgnored) => {
133
+ const synchronous = (pathIgnored !== null) ?
134
+ findInFile(filePath, callback, context) :
135
+ true;
136
+
137
+ if (synchronous) {
138
+ callback(pathIgnored);
139
+ }
140
+ });
141
+ }
142
+
143
+ return synchronous;
144
+ }
145
+
146
+ function findInDirectory(directoryPath, callback, context) {
147
+ let synchronous;
148
+
149
+ const directoryPathIgnored = synchronousIsDirectoryPathIgnored(directoryPath, context);
150
+
151
+ if (directoryPathIgnored !== null) {
152
+ synchronous = true;
153
+
154
+ const directoryPathRootDirectoryPath = isDirectoryPathRootDirectoryPath(directoryPath, context);
155
+
156
+ if (!directoryPathRootDirectoryPath) {
157
+ const { quietly } = context;
158
+
159
+ if (!quietly) {
160
+ const { ruleString } = context;
161
+
162
+ let message = directoryPathIgnored ?
163
+ red(`Ignore ${directoryPath}/`) :
164
+ green(`Permit ${directoryPath}/`);
165
+
166
+ message = `${message} ${ruleString}`;
167
+
168
+ console.log(message);
169
+ }
170
+ }
171
+
172
+ if (!directoryPathIgnored) {
173
+ let { directoriesTotal } = context;
174
+
175
+ directoriesTotal++;
176
+
177
+ Object.assign(context, {
178
+ directoriesTotal
179
+ });
180
+
181
+ const entryNames = readDirectory(directoryPath),
182
+ entryPaths = entryPathsFromEntryNamesAndDirectoryPath(entryNames, directoryPath);
183
+
184
+ synchronous = findInEntries(entryPaths, callback, context);
185
+ }
186
+ } else {
187
+ synchronous = false;
188
+
189
+ asynchronousIsDirectoryPathIgnored(directoryPath, context, (pathIgnored) => {
190
+ const synchronous = (pathIgnored !== null) ?
191
+ findInDirectory(directoryPath, callback, context) :
192
+ true;
193
+
194
+ if (synchronous) {
195
+ callback(pathIgnored);
196
+ }
197
+ });
198
+ }
199
+
200
+ return synchronous;
201
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ const { retrieveRootDirectoryPaths } = require("../configuration"),
4
+ { NO_ROOT_DIRECTORY_PATHS_MESSAGE } = require("../messages");
5
+
6
+ function listRootDirectoryPathsOperation(proceed, abort, context) {
7
+ listRootDirectoryPaths()
8
+
9
+ proceed();
10
+ }
11
+
12
+ function listRootDirectoryPaths() {
13
+ const rootDirectoryPaths = retrieveRootDirectoryPaths(),
14
+ rootDirectoryPathsLength = rootDirectoryPaths.length,
15
+ lastIndex = rootDirectoryPathsLength - 1;
16
+
17
+ if (lastIndex === 0) {
18
+ console.log(NO_ROOT_DIRECTORY_PATHS_MESSAGE);
19
+ }
20
+
21
+ rootDirectoryPaths.forEach((rootDirectoryPath, index) => {
22
+ if (index > 0) {
23
+ console.log(index, rootDirectoryPath);
24
+ }
25
+ });
26
+
27
+ return lastIndex;
28
+ }
29
+
30
+ module.exports = listRootDirectoryPathsOperation;
31
+
32
+ Object.assign(module.exports, {
33
+ listRootDirectoryPaths
34
+ });
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ const { shellUtilities } = require("necessary");
4
+
5
+ const { validateRootDirectoryPath } = require("../../utilities/validate"),
6
+ { INVALID_ROOT_DIRECTORY_PATH_MESSAGE } = require("../../messages"),
7
+ { ADD_ROOT_DIRECTORY_PATH_DESCRIPTION } = require("../../descriptions");
8
+
9
+ const { prompt } = shellUtilities;
10
+
11
+ function addRootDirectoryPathPromptOperation(proceed, abort, context) {
12
+ const { rootDirectoryPath } = context;
13
+
14
+ if (rootDirectoryPath !== null) {
15
+ proceed();
16
+
17
+ return;
18
+ }
19
+
20
+ const description = ADD_ROOT_DIRECTORY_PATH_DESCRIPTION,
21
+ errorMessage = INVALID_ROOT_DIRECTORY_PATH_MESSAGE,
22
+ validationFunction = validateRootDirectoryPath, ///
23
+ options = {
24
+ description,
25
+ errorMessage,
26
+ validationFunction
27
+ };
28
+
29
+ prompt(options, (answer) => {
30
+ const valid = (answer !== null);
31
+
32
+ if(!valid) {
33
+ abort();
34
+
35
+ return;
36
+ }
37
+
38
+ const rootDirectoryPath = answer; ///
39
+
40
+ Object.assign(context, {
41
+ rootDirectoryPath
42
+ });
43
+
44
+ proceed();
45
+ });
46
+ }
47
+
48
+ module.exports = addRootDirectoryPathPromptOperation;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ const { shellUtilities } = require("necessary");
4
+
5
+ const { isAnswerIgnore } = require("../../utilities/prompt"),
6
+ { FILE, DIRECTORY } = require("../../constants"),
7
+ { validateIgnoreOrPermit } = require("../../utilities/validate"),
8
+ { INVALID_IGNORE_OR_PERMIT_MESSAGE } = require("../../messages");
9
+
10
+ const { prompt } = shellUtilities;
11
+
12
+ function ignoreOrPermitPathPromptOperation(proceed, abort, context) {
13
+ const { path, directory } = context,
14
+ fileOrDirectory = directory ?
15
+ DIRECTORY :
16
+ FILE,
17
+ description = `Ignore or permit the '${path}' ${fileOrDirectory}? (i)gnore (p)ermit: `,
18
+ errorMessage = INVALID_IGNORE_OR_PERMIT_MESSAGE,
19
+ validationFunction = validateIgnoreOrPermit, ///
20
+ options = {
21
+ description,
22
+ errorMessage,
23
+ validationFunction
24
+ };
25
+
26
+ prompt(options, (answer) => {
27
+ const valid = (answer !== null);
28
+
29
+ if(!valid) {
30
+ abort();
31
+
32
+ return;
33
+ }
34
+
35
+ const ignore = isAnswerIgnore(answer),
36
+ pathIgnored = ignore; ///
37
+
38
+ Object.assign(context, {
39
+ pathIgnored
40
+ });
41
+
42
+ proceed();
43
+ });
44
+ }
45
+
46
+ module.exports = ignoreOrPermitPathPromptOperation;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ const { shellUtilities } = require("necessary");
4
+
5
+ const { validateIndex } = require("../../utilities/validate"),
6
+ { listRootDirectoryPaths } = require("../../operation/listRootDirectoryPaths"),
7
+ { REMOVE_ROOT_DIRECTORY_PATH_DESCRIPTION } = require("../../descriptions"),
8
+ { INVALID_ROOT_DIRECTORY_PATH_INDEX_MESSAGE } = require("../../messages");
9
+
10
+ const { prompt } = shellUtilities;
11
+
12
+ function removeRootDirectoryPathPromptOperation(proceed, abort, context) {
13
+ const { rootDirectoryPath } = context;
14
+
15
+ if (rootDirectoryPath !== null) {
16
+ proceed();
17
+
18
+ return;
19
+ }
20
+
21
+ const lastIndex = listRootDirectoryPaths();
22
+
23
+ if (lastIndex === 0) {
24
+ abort();
25
+
26
+ return;
27
+ }
28
+
29
+ const description = REMOVE_ROOT_DIRECTORY_PATH_DESCRIPTION,
30
+ errorMessage = INVALID_ROOT_DIRECTORY_PATH_INDEX_MESSAGE,
31
+ validationFunction = (answer) => {
32
+ const valid = validateIndex(answer, lastIndex);
33
+
34
+ return valid;
35
+ }, ///
36
+ options = {
37
+ description,
38
+ errorMessage,
39
+ validationFunction
40
+ };
41
+
42
+ prompt(options, (answer) => {
43
+ const valid = (answer !== null);
44
+
45
+ if(!valid) {
46
+ abort();
47
+
48
+ return;
49
+ }
50
+
51
+ const index = answer; ///
52
+
53
+ Object.assign(context, {
54
+ index
55
+ });
56
+
57
+ proceed();
58
+ });
59
+ }
60
+
61
+ module.exports = removeRootDirectoryPathPromptOperation;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ const { shellUtilities } = require("necessary");
4
+
5
+ const { ruleFromStringAnchoredAndDirectory } = require("../../utilities/rule"),
6
+ { validateGlobStringOrPattern } = require("../../utilities/validate"),
7
+ { GLOB_STRING_OR_REGEX_DESCRIPTION } = require("../../descriptions"),
8
+ { INVALID_GLOB_REGEX_OR_STRING_MESSAGE } = require("../../messages");
9
+
10
+ const { prompt } = shellUtilities;
11
+
12
+ function rulePromptOperation(proceed, abort, context) {
13
+ const { path, directory } = context,
14
+ description = GLOB_STRING_OR_REGEX_DESCRIPTION,
15
+ errorMessage = INVALID_GLOB_REGEX_OR_STRING_MESSAGE,
16
+ initialAnswer = path, ///
17
+ validationFunction = (answer) => {
18
+ const valid = validateGlobStringOrPattern(answer, directory);
19
+
20
+ return valid;
21
+ },
22
+ options = {
23
+ description,
24
+ errorMessage,
25
+ initialAnswer,
26
+ validationFunction
27
+ };
28
+
29
+ prompt(options, (answer) => {
30
+ const valid = (answer !== null);
31
+
32
+ if(!valid) {
33
+ abort();
34
+
35
+ return;
36
+ }
37
+
38
+ const string = answer, ///
39
+ anchored = true,
40
+ rule = ruleFromStringAnchoredAndDirectory(string, anchored, directory);
41
+
42
+ Object.assign(context, {
43
+ rule
44
+ });
45
+
46
+ proceed();
47
+ });
48
+ }
49
+
50
+ module.exports = rulePromptOperation;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ const { retrieveRootDirectoryPaths,
4
+ retrieveIgnoredFilePathRules,
5
+ retrievePermittedFilePathRules,
6
+ retrieveIgnoredDirectoryPathRules,
7
+ retrievePermittedDirectoryPathRules } = require("../configuration");
8
+
9
+ function readConfigurationOperation(proceed, abort, context) {
10
+ const rootDirectoryPaths = retrieveRootDirectoryPaths(),
11
+ ignoredFilePathRules = retrieveIgnoredFilePathRules(),
12
+ permittedFilePathRules = retrievePermittedFilePathRules(),
13
+ ignoredDirectoryPathRules = retrieveIgnoredDirectoryPathRules(),
14
+ permittedDirectoryPathRules = retrievePermittedDirectoryPathRules();
15
+
16
+ Object.assign(context, {
17
+ rootDirectoryPaths,
18
+ ignoredFilePathRules,
19
+ permittedFilePathRules,
20
+ ignoredDirectoryPathRules,
21
+ permittedDirectoryPathRules
22
+ });
23
+
24
+ proceed();
25
+ }
26
+
27
+ module.exports = readConfigurationOperation;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ const { retrieveRootDirectoryPaths } = require("../configuration"),
4
+ { removeRootDirectoryPathByIndex } = require("./removeRootDirectoryPathByIndex");
5
+
6
+ function removeRootDirectoryPathOperation(proceed, abort, context) {
7
+ const { rootDirectoryPath } = context;
8
+
9
+ if (rootDirectoryPath === null) {
10
+ proceed();
11
+
12
+ return;
13
+ }
14
+
15
+ const rootDirectoryPaths = retrieveRootDirectoryPaths(),
16
+ index = rootDirectoryPaths.indexOf(rootDirectoryPath);
17
+
18
+ if (index === -1) {
19
+ abort();
20
+
21
+ return;
22
+ }
23
+
24
+ removeRootDirectoryPathByIndex(index);
25
+
26
+ proceed();
27
+ }
28
+
29
+ module.exports = removeRootDirectoryPathOperation;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ const { retrieveRootDirectoryPaths, updateRootDirectoryPaths } = require("../configuration");
4
+
5
+ function removeRootDirectoryPathByIndexOperation(proceed, abort, context) {
6
+ const { index } = context;
7
+
8
+ if (index === null) {
9
+ proceed();
10
+
11
+ return;
12
+ }
13
+
14
+ removeRootDirectoryPathByIndex(index);
15
+
16
+ proceed();
17
+ }
18
+
19
+ function removeRootDirectoryPathByIndex(index) {
20
+ const start = index, ///
21
+ deleteCount = 1,
22
+ rootDirectoryPaths = retrieveRootDirectoryPaths()
23
+
24
+ rootDirectoryPaths.splice(start, deleteCount);
25
+
26
+ updateRootDirectoryPaths(rootDirectoryPaths);
27
+
28
+ }
29
+
30
+ module.exports = removeRootDirectoryPathByIndexOperation;
31
+
32
+ Object.assign(module.exports, {
33
+ removeRootDirectoryPathByIndex
34
+ });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ const { ruleFromStringAnchoredAndDirectory } = require("../utilities/rule");
4
+
5
+ function ruleOperation(proceed, abort, context) {
6
+ const { dryRun } = context;
7
+
8
+ if (dryRun) {
9
+ proceed();
10
+
11
+ return;
12
+ }
13
+
14
+ const { string } = context,
15
+ directory = false,
16
+ anchored = false,
17
+ rule = ruleFromStringAnchoredAndDirectory(string, anchored, directory);
18
+
19
+ if (rule === null) {
20
+ abort();
21
+
22
+ return;
23
+ }
24
+
25
+ Object.assign(context, {
26
+ rule
27
+ });
28
+
29
+ proceed();
30
+ }
31
+
32
+ module.exports = ruleOperation;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ const { updateIgnoredFilePathRules,
4
+ updatePermittedFilePathRules,
5
+ updateIgnoredDirectoryPathRules,
6
+ updatePermittedDirectoryPathRules } = require("../configuration");
7
+
8
+ function updatePathRulesOperation(proceed, abort, context) {
9
+ const { rule, directory, pathIgnored } = context;
10
+
11
+ pathIgnored ?
12
+ addIgnoreRule(rule, directory, context) :
13
+ addPermitRule(rule, directory, context);
14
+
15
+ proceed();
16
+ }
17
+
18
+ module.exports = updatePathRulesOperation;
19
+
20
+ function addIgnoreRule(rule, directory, context) {
21
+ if (directory) {
22
+ const { ignoredDirectoryPathRules } = context,
23
+ ignoredDirectoryPathRule = rule; ///
24
+
25
+ ignoredDirectoryPathRules.push(ignoredDirectoryPathRule);
26
+
27
+ updateIgnoredDirectoryPathRules(ignoredDirectoryPathRules);
28
+ } else {
29
+ const { ignoredFilePathRules } = context,
30
+ ignoredFilePathRule = rule; ///
31
+
32
+ ignoredFilePathRules.push(ignoredFilePathRule);
33
+
34
+ updateIgnoredFilePathRules(ignoredFilePathRules);
35
+ }
36
+ }
37
+
38
+ function addPermitRule(rule, directory, context) {
39
+ if (directory) {
40
+ const { permittedDirectoryPathRules } = context,
41
+ permittedDirectoryPathRule = rule; ///
42
+
43
+ permittedDirectoryPathRules.push(permittedDirectoryPathRule);
44
+
45
+ updatePermittedDirectoryPathRules(permittedDirectoryPathRules);
46
+ } else {
47
+ const { permittedFilePathRules } = context,
48
+ permittedFilePathRule = rule; ///
49
+
50
+ permittedFilePathRules.push(permittedFilePathRule);
51
+
52
+ updatePermittedFilePathRules(permittedFilePathRules);
53
+ }
54
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ const { validateRootDirectoryPath } = require("../utilities/validate"),
4
+ { INVALID_ROOT_DIRECTORY_PATH_MESSAGE } = require("../messages");
5
+
6
+ function validateRootDirectoryPathOperation(proceed, abort, context) {
7
+ const { rootDirectoryPath } = context;
8
+
9
+ if (rootDirectoryPath === null) {
10
+ proceed();
11
+
12
+ return;
13
+ }
14
+
15
+ const valid = validateRootDirectoryPath(rootDirectoryPath);
16
+
17
+ if (!valid) {
18
+ console.log(INVALID_ROOT_DIRECTORY_PATH_MESSAGE);
19
+
20
+ const rootDirectoryPath = null;
21
+
22
+ Object.assign(context, {
23
+ rootDirectoryPath
24
+ });
25
+ }
26
+
27
+ proceed();
28
+ }
29
+
30
+ module.exports = validateRootDirectoryPathOperation;
package/bin/options.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ const HELP_OPTION = "help",
4
+ VERSION_OPTION = "version",
5
+ QUIETLY_OPTION = "quietly",
6
+ DRY_RUN_OPTION = "dry-run";
7
+
8
+ module.exports = {
9
+ HELP_OPTION,
10
+ VERSION_OPTION,
11
+ QUIETLY_OPTION,
12
+ DRY_RUN_OPTION
13
+ };