@jsenv/snapshot 2.7.1 → 2.7.2
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 -3
- package/src/cli.mjs +0 -54
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/snapshot",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "Snapshot testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"url": "https://github.com/jsenv/core",
|
|
13
13
|
"directory": "packages/independent/snapshot"
|
|
14
14
|
},
|
|
15
|
-
"bin": "./src/cli.mjs",
|
|
16
15
|
"engines": {
|
|
17
16
|
"node": ">=20.0.0"
|
|
18
17
|
},
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"@jsenv/assert": "4.1.13",
|
|
38
37
|
"@jsenv/ast": "6.2.12",
|
|
39
38
|
"@jsenv/exception": "1.0.1",
|
|
40
|
-
"@jsenv/filesystem": "4.9.
|
|
39
|
+
"@jsenv/filesystem": "4.9.8",
|
|
41
40
|
"@jsenv/terminal-recorder": "1.4.2",
|
|
42
41
|
"@jsenv/urls": "2.5.1",
|
|
43
42
|
"@jsenv/utils": "2.1.2",
|
package/src/cli.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { clearDirectorySync } from "@jsenv/filesystem";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
import { parseArgs } from "node:util";
|
|
6
|
-
|
|
7
|
-
const options = {
|
|
8
|
-
help: {
|
|
9
|
-
type: "boolean",
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
const { values, positionals } = parseArgs({
|
|
13
|
-
options,
|
|
14
|
-
allowPositionals: true,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (values.help || positionals.length === 0) {
|
|
18
|
-
console.log(`snapshot: Manage snapshot files generated during tests.
|
|
19
|
-
|
|
20
|
-
Usage: npx @jsenv/snapshot clear [pattern]
|
|
21
|
-
|
|
22
|
-
https://github.com/jsenv/core/tree/main/packages/independent/snapshot
|
|
23
|
-
|
|
24
|
-
pattern: files matching this pattern will be removed; can use "*" and "**"
|
|
25
|
-
`);
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const commandHandlers = {
|
|
30
|
-
clear: (pattern) => {
|
|
31
|
-
const currentDirectoryPath = process.cwd();
|
|
32
|
-
const currentDirectoryUrl = pathToFileURL(`${currentDirectoryPath}/`);
|
|
33
|
-
console.log(`clear files matching ${pattern} in ${currentDirectoryPath}`);
|
|
34
|
-
clearDirectorySync(currentDirectoryUrl, pattern);
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const [command] = positionals;
|
|
39
|
-
const commandHandler = commandHandlers[command];
|
|
40
|
-
|
|
41
|
-
if (!commandHandler) {
|
|
42
|
-
console.error(`Error: unknown command ${command}.`);
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (commandHandler.length) {
|
|
47
|
-
const args = positionals.slice(1);
|
|
48
|
-
if (args.length === 0) {
|
|
49
|
-
console.error(`Error: "${command}" command expect arguments.`);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
await commandHandler(...positionals.slice(1));
|