UNPKG

3.76 kBJavaScriptView Raw
1var path = require("path");
2const getopts = require("getopts");
3const optParams = {
4 alias: {
5 s: "single",
6 g: "group",
7 a: "all",
8 l: "list",
9 c: "cranky",
10 w: "watch",
11 O: "once",
12 N: "novalidation",
13 S: "style",
14 k: "key-query",
15 C: "compose-tests",
16 U: "update",
17 b: "black-and-white",
18 r: "reporter",
19 A: "abbreviations",
20 D: "draft",
21 F: "final",
22 h: "help"
23 },
24 string: ["s", "g", "S", "w", "C", "r", "A"],
25 boolean: ["a", "l", "c", "k", "b", "h", "U", "O", "N", "D", "F"],
26 unknown: option => {
27 throw Error("Unknown option \"" +option + "\"");
28 }
29};
30var config = require("./configs.js");
31if (config.mode === "styleMode") {
32 var styleModeText = " (-S MUST be used in this configuration)";
33} else {
34 var styleModeText = "";
35}
36const usage = "Usage: " + path.basename(process.argv[1])
37 + "\nUsage: runtests.js <-s testName|-g groupName|-a|-l> [-S styleName|-w cslFilePath|-C cslJsonFilePath]\n\n"
38 + " Testing options (exactly one MUST be used):\n"
39 + " -s testName, --single=testName\n"
40 + " Run a single local or standard test fixture.\n"
41 + " -g groupName, --group=groupName\n"
42 + " Run a group of tests with the specified prefix.\n"
43 + " -a, --all\n"
44 + " Run all tests.\n"
45 + " Options for style development" + styleModeText + ":\n"
46 + " -w, --watch\n"
47 + " Path to CSL source file watch for changes, relative to\n"
48 + " repository root.\n"
49 + " -U, --update\n"
50 + " Update style tests from collection in JM Style Samples.\n"
51 + " -k, --key-query (used with -w)\n"
52 + " When tests fail, stop processing and ask whether to\n"
53 + " adopt the processor output as the RESULT. Useful for\n"
54 + " rapidly generating tests for existing styles.\n"
55 + " -A, --abbreviations\n"
56 + " Path to abbreviation files, such as a clone of jurism-abbreviations:\n"
57 + " https://github.com/Juris-M/jurism-abbreviations\n"
58 + " -S, --style\n"
59 + " Override name of test set. (Allows use of tests not\n"
60 + " orginally composed for the CSL file designated by -w)\n"
61 + " -C, --compose-tests\n"
62 + " (Discontinued. Open a collection in JM Style Tests and\n"
63 + " use the -U option instead.)\n"
64 + " Miscellaneous options:\n"
65 + " -F, --final\n"
66 + " Use the published-items library (default)\n"
67 + " -D, --draft\n"
68 + " Use the submissions library\n"
69 + " -c, --cranky\n"
70 + " Validate CSL in selected fixtures instead of running\n"
71 + " tests.\n"
72 + " -O, --once\n"
73 + " Use with the -w option. Exits immediately after running tests.\n"
74 + " -N, --novalidation\n"
75 + " Do not validate before running tests.\n"
76 + " -b, --black-and-white\n"
77 + " Disable color output\n"
78 + " -r, --reporter\n"
79 + " Set the report style. Default is \"landing.\"\n"
80 + " Built-in options are: spec, dot, min, progress.\n"
81 + " If installed via npm, nyanplusreporter (as \"nyan\")\n"
82 + " and mocha-spectrum-reporter (as \"spectrum\") are also\n"
83 + " available."
84 + " -l, --list\n"
85 + " List available groups and styles.";
86const options = getopts(process.argv.slice(2), optParams);
87module.exports = {
88 options: options,
89 usage: usage
90};