leanest 0.1.0 → 0.1.1
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/package.json +2 -2
- package/src/cli.ts +25 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leanest",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Local-first test selector using Jev judgments to determine which tests are affected by a code change",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/baronunread/leanest.git"
|
|
33
|
+
"url": "git+https://github.com/baronunread/leanest.git"
|
|
34
34
|
},
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/baronunread/leanest/issues"
|
package/src/cli.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Sieve } from "./sieve.js";
|
|
|
4
4
|
import { SelectionPolicy } from "./selection-policy.js";
|
|
5
5
|
import { runTests } from "./runner.js";
|
|
6
6
|
|
|
7
|
-
interface Flags {
|
|
7
|
+
export interface Flags {
|
|
8
8
|
_: string[];
|
|
9
9
|
changed?: boolean;
|
|
10
10
|
json?: boolean;
|
|
@@ -26,10 +26,8 @@ async function main(): Promise<number> {
|
|
|
26
26
|
const json = flags.json === true;
|
|
27
27
|
const shadow = flags.shadow === true;
|
|
28
28
|
const full = flags.full === true;
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
// SAFETY: flags.base is a git ref string or undefined
|
|
32
|
-
const base = flags.base as string | undefined;
|
|
29
|
+
const cwd = flags.dir ?? ".";
|
|
30
|
+
const base = flags.base;
|
|
33
31
|
|
|
34
32
|
const sieve = new Sieve(cwd, base);
|
|
35
33
|
|
|
@@ -95,21 +93,24 @@ async function main(): Promise<number> {
|
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
|
|
96
|
+
const VALUE_FLAGS = new Set(["base", "dir"]);
|
|
97
|
+
|
|
98
|
+
export function parseFlags(args: string[]): Flags {
|
|
99
99
|
const flags: Flags = { _: [] };
|
|
100
|
-
for (
|
|
101
|
-
|
|
100
|
+
for (let i = 0; i < args.length; i++) {
|
|
101
|
+
const arg = args[i];
|
|
102
|
+
if (arg?.startsWith("--")) {
|
|
102
103
|
const key = arg.slice(2);
|
|
103
|
-
|
|
104
|
+
const next = args[i + 1];
|
|
105
|
+
if (VALUE_FLAGS.has(key) && next !== undefined && !next.startsWith("-")) {
|
|
106
|
+
flags[key] = next;
|
|
107
|
+
i++;
|
|
108
|
+
} else {
|
|
104
109
|
flags[key] = true;
|
|
105
|
-
} else if (Array.isArray(flags[key])) {
|
|
106
|
-
// SAFETY: flags[key] is already confirmed as string[] via Array.isArray check
|
|
107
|
-
(flags[key] as string[]).push(arg);
|
|
108
110
|
}
|
|
109
|
-
} else if (arg
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} else {
|
|
111
|
+
} else if (arg?.startsWith("-")) {
|
|
112
|
+
flags[arg.slice(1)] = true;
|
|
113
|
+
} else if (arg !== undefined) {
|
|
113
114
|
flags._.push(arg);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
@@ -204,9 +205,11 @@ Examples:
|
|
|
204
205
|
`);
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
main
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
if (import.meta.main) {
|
|
209
|
+
main()
|
|
210
|
+
.then((code) => process.exit(code))
|
|
211
|
+
.catch((error) => {
|
|
212
|
+
console.error(error);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
});
|
|
215
|
+
}
|