doc-detective 2.11.0-dev.4 → 2.11.0-dev.5

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.
@@ -58,5 +58,6 @@
58
58
  "telemetry": {
59
59
  "send": true,
60
60
  "userId": "Doc Detective Repo"
61
- }
61
+ },
62
+ "defaultCommand": "runTests"
62
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doc-detective",
3
- "version": "2.11.0-dev.4",
3
+ "version": "2.11.0-dev.5",
4
4
  "description": "Treat doc content as testable assertions to validate doc accuracy and product UX.",
5
5
  "bin": {
6
6
  "doc-detective": "src/index.js"
Binary file
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const { runTests, runCoverage } = require("doc-detective-core");
4
4
  const { setArgs, setConfig, outputResults, setMeta } = require("./utils");
@@ -11,13 +11,12 @@ function complete(commands) {
11
11
  return function (str) {
12
12
  var i;
13
13
  var ret = [];
14
- for (i=0; i< commands.length; i++) {
15
- if (commands[i].indexOf(str) == 0)
16
- ret.push(commands[i]);
14
+ for (i = 0; i < commands.length; i++) {
15
+ if (commands[i].indexOf(str) == 0) ret.push(commands[i]);
17
16
  }
18
17
  return ret;
19
18
  };
20
- };
19
+ }
21
20
 
22
21
  // Run
23
22
  setMeta();
@@ -31,20 +30,6 @@ async function main(argv) {
31
30
  );
32
31
  // `command` is the next argument after `doc-detective` or `src/index.js`
33
32
  let command = argv[index + 1];
34
- // If no command, prompt user to select a command
35
- if (command !== "runTests" && command !== "runCoverage") {
36
- const ask = `
37
- Welcome to Doc Detective. Choose a command:
38
- - 'runTests' - Run tests defined in specifications and documentation source files.
39
- - 'runCoverage' - Calculate test coverage of doc content.
40
-
41
- You can skip this next time by running 'npx doc-detective <command>'. You can also set 'defaultCommand' in your .doc-detective.json config file.
42
-
43
- For more info, visit https://doc-detective.com.
44
-
45
- Command: `;
46
- command = prompt({ask, value: "runTests", autocomplete: complete(["runTests", "runCoverage"])});
47
- }
48
33
  // Set args
49
34
  argv = setArgs(argv);
50
35
  // Get .doc-detective.json config, if it exists
@@ -55,6 +40,26 @@ Command: `;
55
40
  }
56
41
  // Set config
57
42
  config = setConfig(config, argv);
43
+ command = command || config.defaultCommand;
44
+ // If no command, prompt user to select a command
45
+ if (command !== "runTests" && command !== "runCoverage") {
46
+ const ask = `
47
+ Welcome to Doc Detective. Choose a command:
48
+ - 'runTests' - Run tests defined in specifications and documentation source files.
49
+ - 'runCoverage' - Calculate test coverage of doc content.
50
+
51
+ You can skip this next time by running 'npx doc-detective <command>'. You can also set 'defaultCommand' in your .doc-detective.json config file.
52
+
53
+ For more info, visit https://doc-detective.com.
54
+
55
+ Command: `;
56
+ command = prompt({
57
+ ask,
58
+ value: "runTests",
59
+ autocomplete: complete(["runTests", "runCoverage"]),
60
+ });
61
+ }
62
+
58
63
  // Run command
59
64
  let results = {};
60
65
  let outputDir;