find-cli 1.6.2 → 1.6.3

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.
@@ -17,8 +17,6 @@ function findAction(string, dryRun, format, quietly, interactive) {
17
17
  ],
18
18
  rule = null,
19
19
  lines = [],
20
- anchored = false,
21
- directory = false,
22
20
  linesTotal = 0,
23
21
  filesTotal = 0,
24
22
  directoriesTotal = 0,
@@ -31,8 +29,6 @@ function findAction(string, dryRun, format, quietly, interactive) {
31
29
  interactive,
32
30
  rule,
33
31
  lines,
34
- anchored,
35
- directory,
36
32
  linesTotal,
37
33
  filesTotal,
38
34
  directoriesTotal,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const rulePromptOperation = require("../operation/prompt/rule"),
3
+ const pathRulePromptOperation = require("../operation/prompt/pathRule"),
4
4
  updatePathRulesOperation = require("../operation/updatePatRules"),
5
5
  ignoreOrPermitPathPromptOperation = require("../operation/prompt/ignoreOrPermitPath");
6
6
 
@@ -33,31 +33,25 @@ module.exports = {
33
33
  function asynchronousIsPathIgnored(path, directory, context, callback) {
34
34
  const operations = [
35
35
  ignoreOrPermitPathPromptOperation,
36
- rulePromptOperation,
36
+ pathRulePromptOperation,
37
37
  updatePathRulesOperation
38
38
  ],
39
- rule = null,
40
- dryRun = false,
41
- anchored = true,
42
- interactive = true,
39
+ pathRule = null,
43
40
  pathIgnored = null;
44
41
 
45
42
  Object.assign(context, {
46
43
  path,
47
44
  directory,
48
- rule,
49
- dryRun,
50
- anchored,
51
- interactive,
45
+ pathRule,
52
46
  pathIgnored
53
47
  });
54
48
 
55
49
  executeOperations(operations, (completed) => {
56
50
  const { pathIgnored } = context;
57
51
 
58
- delete context.rule;
59
52
  delete context.path;
60
53
  delete context.directory;
54
+ delete context.pathRule;
61
55
  delete context.pathIgnored;
62
56
 
63
57
  callback(pathIgnored);
@@ -19,7 +19,11 @@ function findOperation(proceed, abort, context) {
19
19
  synchronous = findInEntries(entryPaths, (pathIgnored) => {
20
20
  if (pathIgnored === null) {
21
21
  abort();
22
+
23
+ return;
22
24
  }
25
+
26
+ proceed();
23
27
  }, context);
24
28
 
25
29
  if (synchronous) {
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ const { shellUtilities } = require("necessary");
4
+
5
+ const { validateGlobStringOrPattern } = require("../../utilities/validate"),
6
+ { GLOB_STRING_OR_REGEX_DESCRIPTION } = require("../../descriptions"),
7
+ { ruleFromStringAnchoredAndDirectory } = require("../../utilities/rule"),
8
+ { INVALID_GLOB_REGEX_OR_STRING_MESSAGE } = require("../../messages");
9
+
10
+ const { prompt } = shellUtilities;
11
+
12
+ function pathRulePromptOperation(proceed, abort, context) {
13
+ const { path, directory } = context,
14
+ anchored = true,
15
+ description = GLOB_STRING_OR_REGEX_DESCRIPTION,
16
+ errorMessage = INVALID_GLOB_REGEX_OR_STRING_MESSAGE,
17
+ initialAnswer = path, ///
18
+ validationFunction = (answer) => {
19
+ const valid = validateGlobStringOrPattern(answer, anchored, directory);
20
+
21
+ return valid;
22
+ },
23
+ options = {
24
+ description,
25
+ errorMessage,
26
+ initialAnswer,
27
+ validationFunction
28
+ };
29
+
30
+ prompt(options, (answer) => {
31
+ const valid = (answer !== null);
32
+
33
+ if(!valid) {
34
+ abort();
35
+
36
+ return;
37
+ }
38
+
39
+ const string = answer, ///
40
+ rule = ruleFromStringAnchoredAndDirectory(string, anchored, directory),
41
+ pathRule = rule; ///
42
+
43
+ Object.assign(context, {
44
+ pathRule
45
+ });
46
+
47
+ proceed();
48
+ });
49
+ }
50
+
51
+ module.exports = pathRulePromptOperation;
@@ -19,7 +19,9 @@ function ruleOperation(proceed, abort, context) {
19
19
  return;
20
20
  }
21
21
 
22
- const { string, anchored, directory } = context,
22
+ const { string } = context,
23
+ anchored = true,
24
+ directory = false,
23
25
  rule = ruleFromStringAnchoredAndDirectory(string, anchored, directory);
24
26
 
25
27
  if (rule === null) {
@@ -6,28 +6,28 @@ const { updateIgnoredFilePathRules,
6
6
  updatePermittedDirectoryPathRules } = require("../configuration");
7
7
 
8
8
  function updatePathRulesOperation(proceed, abort, context) {
9
- const { rule, directory, pathIgnored } = context;
9
+ const { pathRule, directory, pathIgnored } = context;
10
10
 
11
11
  pathIgnored ?
12
- addIgnoreRule(rule, directory, context) :
13
- addPermitRule(rule, directory, context);
12
+ addIgnoreRule(pathRule, directory, context) :
13
+ addPermitRule(pathRule, directory, context);
14
14
 
15
15
  proceed();
16
16
  }
17
17
 
18
18
  module.exports = updatePathRulesOperation;
19
19
 
20
- function addIgnoreRule(rule, directory, context) {
20
+ function addIgnoreRule(pathRule, directory, context) {
21
21
  if (directory) {
22
22
  const { ignoredDirectoryPathRules } = context,
23
- ignoredDirectoryPathRule = rule; ///
23
+ ignoredDirectoryPathRule = pathRule; ///
24
24
 
25
25
  ignoredDirectoryPathRules.push(ignoredDirectoryPathRule);
26
26
 
27
27
  updateIgnoredDirectoryPathRules(ignoredDirectoryPathRules);
28
28
  } else {
29
29
  const { ignoredFilePathRules } = context,
30
- ignoredFilePathRule = rule; ///
30
+ ignoredFilePathRule = pathRule; ///
31
31
 
32
32
  ignoredFilePathRules.push(ignoredFilePathRule);
33
33
 
@@ -35,17 +35,17 @@ function addIgnoreRule(rule, directory, context) {
35
35
  }
36
36
  }
37
37
 
38
- function addPermitRule(rule, directory, context) {
38
+ function addPermitRule(pathRule, directory, context) {
39
39
  if (directory) {
40
40
  const { permittedDirectoryPathRules } = context,
41
- permittedDirectoryPathRule = rule; ///
41
+ permittedDirectoryPathRule = pathRule; ///
42
42
 
43
43
  permittedDirectoryPathRules.push(permittedDirectoryPathRule);
44
44
 
45
45
  updatePermittedDirectoryPathRules(permittedDirectoryPathRules);
46
46
  } else {
47
47
  const { permittedFilePathRules } = context,
48
- permittedFilePathRule = rule; ///
48
+ permittedFilePathRule = pathRule; ///
49
49
 
50
50
  permittedFilePathRules.push(permittedFilePathRule);
51
51
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "find-cli",
3
3
  "author": "James Smith",
4
- "version": "1.6.2",
4
+ "version": "1.6.3",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/find-cli",
7
7
  "description": "An alternative to grep.",