uni-run 1.0.6 → 1.0.7
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/dist/arg-helper.cjs +13 -8
- package/dist/arg-helper.d.cts +14 -6
- package/dist/arg-helper.d.mts +14 -6
- package/dist/arg-helper.mjs +13 -8
- package/dist/arg.d.cts +24 -10
- package/dist/arg.d.mts +24 -10
- package/dist/execution/index.cjs +5 -3
- package/dist/execution/index.mjs +5 -3
- package/dist/execution/watcher.cjs +16 -20
- package/dist/execution/watcher.d.cts +1 -1
- package/dist/execution/watcher.d.mts +1 -1
- package/dist/execution/watcher.mjs +16 -20
- package/package.json +3 -4
package/dist/arg-helper.cjs
CHANGED
|
@@ -16,9 +16,9 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
16
16
|
.aliases('w')
|
|
17
17
|
.default(true)
|
|
18
18
|
.description('Watch for changes'),
|
|
19
|
-
|
|
19
|
+
exit: noarg_1.default.boolean()
|
|
20
20
|
.default(false)
|
|
21
|
-
.description('
|
|
21
|
+
.description('Exit after code execution, disabling `watch` and `reloadKey`'),
|
|
22
22
|
clear: noarg_1.default.boolean()
|
|
23
23
|
.aliases('c')
|
|
24
24
|
.default(true)
|
|
@@ -31,10 +31,14 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
31
31
|
.aliases('e')
|
|
32
32
|
.default([])
|
|
33
33
|
.description('Looks for changes only of the given extensions'),
|
|
34
|
-
|
|
35
|
-
.aliases('
|
|
34
|
+
include: noarg_1.default.array(noarg_1.default.string())
|
|
35
|
+
.aliases('in')
|
|
36
36
|
.default([])
|
|
37
|
-
.description('
|
|
37
|
+
.description('Only watch the given folders/files'),
|
|
38
|
+
exclude: noarg_1.default.array(noarg_1.default.string())
|
|
39
|
+
.aliases('ex')
|
|
40
|
+
.default([])
|
|
41
|
+
.description('Exclude the given folders/files'),
|
|
38
42
|
bench: noarg_1.default.boolean()
|
|
39
43
|
.aliases('b')
|
|
40
44
|
.description('Calculate the execution time'),
|
|
@@ -85,10 +89,11 @@ function mapFlagsToOptions(flags, bin) {
|
|
|
85
89
|
benchmark: (_a = flags.bench) !== null && _a !== void 0 ? _a : Boolean(flags.benchPrefix),
|
|
86
90
|
benchmarkPrefix: flags.benchPrefix,
|
|
87
91
|
clearOnReload: flags.clear,
|
|
88
|
-
keystrokeReload: flags.
|
|
89
|
-
watch: flags.
|
|
92
|
+
keystrokeReload: flags.exit ? false : flags.reloadKey,
|
|
93
|
+
watch: flags.exit ? false : flags.watch,
|
|
90
94
|
watchDelay: flags.delay,
|
|
91
|
-
|
|
95
|
+
watchInclude: flags.include,
|
|
96
|
+
watchExclude: flags.exclude,
|
|
92
97
|
watchExtensions: (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.getRelatedExts()) || [],
|
|
93
98
|
tsNode: flags['tsn'],
|
|
94
99
|
env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
|
package/dist/arg-helper.d.cts
CHANGED
|
@@ -15,10 +15,10 @@ export declare const executionConfig: {
|
|
|
15
15
|
default: true;
|
|
16
16
|
description: "Watch for changes";
|
|
17
17
|
}>;
|
|
18
|
-
readonly
|
|
18
|
+
readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
19
19
|
required: true;
|
|
20
20
|
default: false;
|
|
21
|
-
description: "
|
|
21
|
+
description: "Exit after code execution, disabling `watch` and `reloadKey`";
|
|
22
22
|
}>;
|
|
23
23
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
24
24
|
aliases: ["c"];
|
|
@@ -39,12 +39,19 @@ export declare const executionConfig: {
|
|
|
39
39
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
40
40
|
description: "Looks for changes only of the given extensions";
|
|
41
41
|
}>;
|
|
42
|
-
readonly
|
|
43
|
-
aliases: ["
|
|
42
|
+
readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
43
|
+
aliases: ["in"];
|
|
44
44
|
required: true;
|
|
45
45
|
default: never[];
|
|
46
46
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
47
|
-
description: "
|
|
47
|
+
description: "Only watch the given folders/files";
|
|
48
|
+
}>;
|
|
49
|
+
readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
50
|
+
aliases: ["ex"];
|
|
51
|
+
required: true;
|
|
52
|
+
default: never[];
|
|
53
|
+
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
54
|
+
description: "Exclude the given folders/files";
|
|
48
55
|
}>;
|
|
49
56
|
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
50
57
|
aliases: ["b"];
|
|
@@ -114,7 +121,8 @@ export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, b
|
|
|
114
121
|
keystrokeReload: boolean;
|
|
115
122
|
watch: boolean;
|
|
116
123
|
watchDelay: number;
|
|
117
|
-
|
|
124
|
+
watchInclude: string[];
|
|
125
|
+
watchExclude: string[];
|
|
118
126
|
watchExtensions: string[];
|
|
119
127
|
tsNode: boolean;
|
|
120
128
|
env: NodeJS.ProcessEnv;
|
package/dist/arg-helper.d.mts
CHANGED
|
@@ -15,10 +15,10 @@ export declare const executionConfig: {
|
|
|
15
15
|
default: true;
|
|
16
16
|
description: "Watch for changes";
|
|
17
17
|
}>;
|
|
18
|
-
readonly
|
|
18
|
+
readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
19
19
|
required: true;
|
|
20
20
|
default: false;
|
|
21
|
-
description: "
|
|
21
|
+
description: "Exit after code execution, disabling `watch` and `reloadKey`";
|
|
22
22
|
}>;
|
|
23
23
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
24
24
|
aliases: ["c"];
|
|
@@ -39,12 +39,19 @@ export declare const executionConfig: {
|
|
|
39
39
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
40
40
|
description: "Looks for changes only of the given extensions";
|
|
41
41
|
}>;
|
|
42
|
-
readonly
|
|
43
|
-
aliases: ["
|
|
42
|
+
readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
43
|
+
aliases: ["in"];
|
|
44
44
|
required: true;
|
|
45
45
|
default: never[];
|
|
46
46
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
47
|
-
description: "
|
|
47
|
+
description: "Only watch the given folders/files";
|
|
48
|
+
}>;
|
|
49
|
+
readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
50
|
+
aliases: ["ex"];
|
|
51
|
+
required: true;
|
|
52
|
+
default: never[];
|
|
53
|
+
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
54
|
+
description: "Exclude the given folders/files";
|
|
48
55
|
}>;
|
|
49
56
|
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
50
57
|
aliases: ["b"];
|
|
@@ -114,7 +121,8 @@ export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, b
|
|
|
114
121
|
keystrokeReload: boolean;
|
|
115
122
|
watch: boolean;
|
|
116
123
|
watchDelay: number;
|
|
117
|
-
|
|
124
|
+
watchInclude: string[];
|
|
125
|
+
watchExclude: string[];
|
|
118
126
|
watchExtensions: string[];
|
|
119
127
|
tsNode: boolean;
|
|
120
128
|
env: NodeJS.ProcessEnv;
|
package/dist/arg-helper.mjs
CHANGED
|
@@ -9,9 +9,9 @@ export const executionConfig = NoArg.defineConfig({
|
|
|
9
9
|
.aliases('w')
|
|
10
10
|
.default(true)
|
|
11
11
|
.description('Watch for changes'),
|
|
12
|
-
|
|
12
|
+
exit: NoArg.boolean()
|
|
13
13
|
.default(false)
|
|
14
|
-
.description('
|
|
14
|
+
.description('Exit after code execution, disabling `watch` and `reloadKey`'),
|
|
15
15
|
clear: NoArg.boolean()
|
|
16
16
|
.aliases('c')
|
|
17
17
|
.default(true)
|
|
@@ -24,10 +24,14 @@ export const executionConfig = NoArg.defineConfig({
|
|
|
24
24
|
.aliases('e')
|
|
25
25
|
.default([])
|
|
26
26
|
.description('Looks for changes only of the given extensions'),
|
|
27
|
-
|
|
28
|
-
.aliases('
|
|
27
|
+
include: NoArg.array(NoArg.string())
|
|
28
|
+
.aliases('in')
|
|
29
29
|
.default([])
|
|
30
|
-
.description('
|
|
30
|
+
.description('Only watch the given folders/files'),
|
|
31
|
+
exclude: NoArg.array(NoArg.string())
|
|
32
|
+
.aliases('ex')
|
|
33
|
+
.default([])
|
|
34
|
+
.description('Exclude the given folders/files'),
|
|
31
35
|
bench: NoArg.boolean()
|
|
32
36
|
.aliases('b')
|
|
33
37
|
.description('Calculate the execution time'),
|
|
@@ -78,10 +82,11 @@ export function mapFlagsToOptions(flags, bin) {
|
|
|
78
82
|
benchmark: (_a = flags.bench) !== null && _a !== void 0 ? _a : Boolean(flags.benchPrefix),
|
|
79
83
|
benchmarkPrefix: flags.benchPrefix,
|
|
80
84
|
clearOnReload: flags.clear,
|
|
81
|
-
keystrokeReload: flags.
|
|
82
|
-
watch: flags.
|
|
85
|
+
keystrokeReload: flags.exit ? false : flags.reloadKey,
|
|
86
|
+
watch: flags.exit ? false : flags.watch,
|
|
83
87
|
watchDelay: flags.delay,
|
|
84
|
-
|
|
88
|
+
watchInclude: flags.include,
|
|
89
|
+
watchExclude: flags.exclude,
|
|
85
90
|
watchExtensions: (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.getRelatedExts()) || [],
|
|
86
91
|
tsNode: flags['tsn'],
|
|
87
92
|
env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
|
package/dist/arg.d.cts
CHANGED
|
@@ -34,10 +34,10 @@ export declare const app: NoArg<"uni-run", {
|
|
|
34
34
|
default: true;
|
|
35
35
|
description: "Watch for changes";
|
|
36
36
|
}>;
|
|
37
|
-
readonly
|
|
37
|
+
readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
38
38
|
required: true;
|
|
39
39
|
default: false;
|
|
40
|
-
description: "
|
|
40
|
+
description: "Exit after code execution, disabling `watch` and `reloadKey`";
|
|
41
41
|
}>;
|
|
42
42
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
43
43
|
aliases: ["c"];
|
|
@@ -58,12 +58,19 @@ export declare const app: NoArg<"uni-run", {
|
|
|
58
58
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
59
59
|
description: "Looks for changes only of the given extensions";
|
|
60
60
|
}>;
|
|
61
|
-
readonly
|
|
62
|
-
aliases: ["
|
|
61
|
+
readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
62
|
+
aliases: ["in"];
|
|
63
63
|
required: true;
|
|
64
64
|
default: never[];
|
|
65
65
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
66
|
-
description: "
|
|
66
|
+
description: "Only watch the given folders/files";
|
|
67
|
+
}>;
|
|
68
|
+
readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
69
|
+
aliases: ["ex"];
|
|
70
|
+
required: true;
|
|
71
|
+
default: never[];
|
|
72
|
+
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
73
|
+
description: "Exclude the given folders/files";
|
|
67
74
|
}>;
|
|
68
75
|
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
69
76
|
aliases: ["b"];
|
|
@@ -145,10 +152,10 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
145
152
|
default: true;
|
|
146
153
|
description: "Watch for changes";
|
|
147
154
|
}>;
|
|
148
|
-
readonly
|
|
155
|
+
readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
149
156
|
required: true;
|
|
150
157
|
default: false;
|
|
151
|
-
description: "
|
|
158
|
+
description: "Exit after code execution, disabling `watch` and `reloadKey`";
|
|
152
159
|
}>;
|
|
153
160
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
154
161
|
aliases: ["c"];
|
|
@@ -169,12 +176,19 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
169
176
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
170
177
|
description: "Looks for changes only of the given extensions";
|
|
171
178
|
}>;
|
|
172
|
-
readonly
|
|
173
|
-
aliases: ["
|
|
179
|
+
readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
180
|
+
aliases: ["in"];
|
|
181
|
+
required: true;
|
|
182
|
+
default: never[];
|
|
183
|
+
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
184
|
+
description: "Only watch the given folders/files";
|
|
185
|
+
}>;
|
|
186
|
+
readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
187
|
+
aliases: ["ex"];
|
|
174
188
|
required: true;
|
|
175
189
|
default: never[];
|
|
176
190
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
177
|
-
description: "
|
|
191
|
+
description: "Exclude the given folders/files";
|
|
178
192
|
}>;
|
|
179
193
|
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
180
194
|
aliases: ["b"];
|
package/dist/arg.d.mts
CHANGED
|
@@ -34,10 +34,10 @@ export declare const app: NoArg<"uni-run", {
|
|
|
34
34
|
default: true;
|
|
35
35
|
description: "Watch for changes";
|
|
36
36
|
}>;
|
|
37
|
-
readonly
|
|
37
|
+
readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
38
38
|
required: true;
|
|
39
39
|
default: false;
|
|
40
|
-
description: "
|
|
40
|
+
description: "Exit after code execution, disabling `watch` and `reloadKey`";
|
|
41
41
|
}>;
|
|
42
42
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
43
43
|
aliases: ["c"];
|
|
@@ -58,12 +58,19 @@ export declare const app: NoArg<"uni-run", {
|
|
|
58
58
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
59
59
|
description: "Looks for changes only of the given extensions";
|
|
60
60
|
}>;
|
|
61
|
-
readonly
|
|
62
|
-
aliases: ["
|
|
61
|
+
readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
62
|
+
aliases: ["in"];
|
|
63
63
|
required: true;
|
|
64
64
|
default: never[];
|
|
65
65
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
66
|
-
description: "
|
|
66
|
+
description: "Only watch the given folders/files";
|
|
67
|
+
}>;
|
|
68
|
+
readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
69
|
+
aliases: ["ex"];
|
|
70
|
+
required: true;
|
|
71
|
+
default: never[];
|
|
72
|
+
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
73
|
+
description: "Exclude the given folders/files";
|
|
67
74
|
}>;
|
|
68
75
|
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
69
76
|
aliases: ["b"];
|
|
@@ -145,10 +152,10 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
145
152
|
default: true;
|
|
146
153
|
description: "Watch for changes";
|
|
147
154
|
}>;
|
|
148
|
-
readonly
|
|
155
|
+
readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
149
156
|
required: true;
|
|
150
157
|
default: false;
|
|
151
|
-
description: "
|
|
158
|
+
description: "Exit after code execution, disabling `watch` and `reloadKey`";
|
|
152
159
|
}>;
|
|
153
160
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
154
161
|
aliases: ["c"];
|
|
@@ -169,12 +176,19 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
169
176
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
170
177
|
description: "Looks for changes only of the given extensions";
|
|
171
178
|
}>;
|
|
172
|
-
readonly
|
|
173
|
-
aliases: ["
|
|
179
|
+
readonly include: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
180
|
+
aliases: ["in"];
|
|
181
|
+
required: true;
|
|
182
|
+
default: never[];
|
|
183
|
+
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
184
|
+
description: "Only watch the given folders/files";
|
|
185
|
+
}>;
|
|
186
|
+
readonly exclude: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
187
|
+
aliases: ["ex"];
|
|
174
188
|
required: true;
|
|
175
189
|
default: never[];
|
|
176
190
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
177
|
-
description: "
|
|
191
|
+
description: "Exclude the given folders/files";
|
|
178
192
|
}>;
|
|
179
193
|
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
180
194
|
aliases: ["b"];
|
package/dist/execution/index.cjs
CHANGED
|
@@ -65,11 +65,13 @@ class Execution {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
if (this.options.watch) {
|
|
68
|
-
(0, watcher_1.default)(this.options.cwd,
|
|
69
|
-
|
|
68
|
+
(0, watcher_1.default)(this.options.cwd, this.options.watchInclude.length
|
|
69
|
+
? this.options.watchInclude
|
|
70
|
+
: [this.options.cwd], () => this.runProcess(), {
|
|
71
|
+
ignore: this.options.watchExclude,
|
|
70
72
|
debounceDelay: this.options.watchDelay,
|
|
71
73
|
extensions: new Set(this.options.watchExtensions),
|
|
72
|
-
}
|
|
74
|
+
});
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
runProcess() {
|
package/dist/execution/index.mjs
CHANGED
|
@@ -37,11 +37,13 @@ export default class Execution {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
if (this.options.watch) {
|
|
40
|
-
watcher(this.options.cwd,
|
|
41
|
-
|
|
40
|
+
watcher(this.options.cwd, this.options.watchInclude.length
|
|
41
|
+
? this.options.watchInclude
|
|
42
|
+
: [this.options.cwd], () => this.runProcess(), {
|
|
43
|
+
ignore: this.options.watchExclude,
|
|
42
44
|
debounceDelay: this.options.watchDelay,
|
|
43
45
|
extensions: new Set(this.options.watchExtensions),
|
|
44
|
-
}
|
|
46
|
+
});
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
runProcess() {
|
|
@@ -31,20 +31,22 @@ const path = __importStar(require("path"));
|
|
|
31
31
|
const gitignore_1 = __importDefault(require("./gitignore.cjs"));
|
|
32
32
|
const chokidar = __importStar(require("chokidar"));
|
|
33
33
|
const debounce_1 = require("../utils/debounce.cjs");
|
|
34
|
-
function default_1(
|
|
35
|
-
const ig = (0, gitignore_1.default)(
|
|
34
|
+
function default_1(cwd, targets, callback, options) {
|
|
35
|
+
const ig = (0, gitignore_1.default)(cwd, options.ignore);
|
|
36
36
|
const debounce = (0, debounce_1.createDebounce)(options.debounceDelay);
|
|
37
|
-
const watcher = chokidar.watch(
|
|
37
|
+
const watcher = chokidar.watch(targets, {
|
|
38
38
|
ignored: (filePath) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (options.extensions.size) {
|
|
45
|
-
const ext = path.extname(relativePath).slice(1);
|
|
46
|
-
if (ext && !options.extensions.has(ext))
|
|
39
|
+
for (const target of targets) {
|
|
40
|
+
const relativePath = path.relative(target, filePath);
|
|
41
|
+
if (!relativePath)
|
|
42
|
+
return false;
|
|
43
|
+
if (ig.ignores(relativePath))
|
|
47
44
|
return true;
|
|
45
|
+
if (options.extensions.size) {
|
|
46
|
+
const ext = path.extname(relativePath).slice(1);
|
|
47
|
+
if (ext && !options.extensions.has(ext))
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
return false;
|
|
50
52
|
},
|
|
@@ -52,13 +54,7 @@ function default_1(dir, options, callback) {
|
|
|
52
54
|
ignoreInitial: true,
|
|
53
55
|
persistent: true,
|
|
54
56
|
});
|
|
55
|
-
watcher.on('add', (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
watcher.on('change', (event) => {
|
|
59
|
-
debounce(() => callback());
|
|
60
|
-
});
|
|
61
|
-
watcher.on('unlink', () => {
|
|
62
|
-
debounce(() => callback());
|
|
63
|
-
});
|
|
57
|
+
watcher.on('add', () => debounce(() => callback()));
|
|
58
|
+
watcher.on('change', () => debounce(() => callback()));
|
|
59
|
+
watcher.on('unlink', () => debounce(() => callback()));
|
|
64
60
|
}
|
|
@@ -3,4 +3,4 @@ export type WatcherOptions = {
|
|
|
3
3
|
extensions: Set<string>;
|
|
4
4
|
debounceDelay: number;
|
|
5
5
|
};
|
|
6
|
-
export default function (
|
|
6
|
+
export default function (cwd: string, targets: string | string[], callback: () => void, options: WatcherOptions): void;
|
|
@@ -3,4 +3,4 @@ export type WatcherOptions = {
|
|
|
3
3
|
extensions: Set<string>;
|
|
4
4
|
debounceDelay: number;
|
|
5
5
|
};
|
|
6
|
-
export default function (
|
|
6
|
+
export default function (cwd: string, targets: string | string[], callback: () => void, options: WatcherOptions): void;
|
|
@@ -2,20 +2,22 @@ import * as path from "path";
|
|
|
2
2
|
import gitignore from "./gitignore.mjs";
|
|
3
3
|
import * as chokidar from "chokidar";
|
|
4
4
|
import { createDebounce } from "../utils/debounce.mjs";
|
|
5
|
-
export default function (
|
|
6
|
-
const ig = gitignore(
|
|
5
|
+
export default function (cwd, targets, callback, options) {
|
|
6
|
+
const ig = gitignore(cwd, options.ignore);
|
|
7
7
|
const debounce = createDebounce(options.debounceDelay);
|
|
8
|
-
const watcher = chokidar.watch(
|
|
8
|
+
const watcher = chokidar.watch(targets, {
|
|
9
9
|
ignored: (filePath) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (options.extensions.size) {
|
|
16
|
-
const ext = path.extname(relativePath).slice(1);
|
|
17
|
-
if (ext && !options.extensions.has(ext))
|
|
10
|
+
for (const target of targets) {
|
|
11
|
+
const relativePath = path.relative(target, filePath);
|
|
12
|
+
if (!relativePath)
|
|
13
|
+
return false;
|
|
14
|
+
if (ig.ignores(relativePath))
|
|
18
15
|
return true;
|
|
16
|
+
if (options.extensions.size) {
|
|
17
|
+
const ext = path.extname(relativePath).slice(1);
|
|
18
|
+
if (ext && !options.extensions.has(ext))
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
return false;
|
|
21
23
|
},
|
|
@@ -23,13 +25,7 @@ export default function (dir, options, callback) {
|
|
|
23
25
|
ignoreInitial: true,
|
|
24
26
|
persistent: true,
|
|
25
27
|
});
|
|
26
|
-
watcher.on('add', (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
watcher.on('change', (event) => {
|
|
30
|
-
debounce(() => callback());
|
|
31
|
-
});
|
|
32
|
-
watcher.on('unlink', () => {
|
|
33
|
-
debounce(() => callback());
|
|
34
|
-
});
|
|
28
|
+
watcher.on('add', () => debounce(() => callback()));
|
|
29
|
+
watcher.on('change', () => debounce(() => callback()));
|
|
30
|
+
watcher.on('unlink', () => debounce(() => callback()));
|
|
35
31
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uni-run",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Universal Runner for many language",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npmize dev",
|
|
7
7
|
"build": "npmize build",
|
|
8
8
|
"tsc": "tsc --watch --noEmit",
|
|
9
9
|
"lab": "run ./src/__lab__/index.ts",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"mjs": "node --watch ./dist/__lab__/index.mjs"
|
|
10
|
+
"cjs": "node ./dist/__lab__/index.cjs",
|
|
11
|
+
"mjs": "node ./dist/__lab__/index.mjs"
|
|
13
12
|
},
|
|
14
13
|
"main": "./dist/index.cjs",
|
|
15
14
|
"module": "./dist/index.mjs",
|