uni-run 1.1.25 → 2.0.0

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.
Files changed (64) hide show
  1. package/README.md +100 -149
  2. package/dist/app-31LC_vYS.js +28304 -0
  3. package/dist/app-31LC_vYS.js.map +1 -0
  4. package/dist/app-IwNLL71t.mjs +28239 -0
  5. package/dist/app-IwNLL71t.mjs.map +1 -0
  6. package/dist/run.cjs +5 -0
  7. package/dist/run.cjs.map +1 -0
  8. package/dist/run.d.cts +1 -0
  9. package/dist/run.d.mts +1 -0
  10. package/dist/run.mjs +6 -0
  11. package/dist/run.mjs.map +1 -0
  12. package/dist/rux.cjs +6 -0
  13. package/dist/rux.cjs.map +1 -0
  14. package/dist/rux.d.cts +1 -0
  15. package/dist/rux.d.mts +1 -0
  16. package/dist/rux.mjs +7 -0
  17. package/dist/rux.mjs.map +1 -0
  18. package/package.json +54 -30
  19. package/dist/app.d.ts +0 -1
  20. package/dist/app.js +0 -97
  21. package/dist/arg.d.ts +0 -229
  22. package/dist/arg.js +0 -18
  23. package/dist/argHelper.d.ts +0 -108
  24. package/dist/argHelper.js +0 -94
  25. package/dist/bin.d.ts +0 -2
  26. package/dist/bin.js +0 -6
  27. package/dist/bix.d.ts +0 -2
  28. package/dist/bix.js +0 -8
  29. package/dist/execution/gitignore.d.ts +0 -1
  30. package/dist/execution/gitignore.js +0 -40
  31. package/dist/execution/index.d.ts +0 -21
  32. package/dist/execution/index.js +0 -177
  33. package/dist/execution/kill-process.d.ts +0 -2
  34. package/dist/execution/kill-process.js +0 -50
  35. package/dist/execution/watcher.d.ts +0 -6
  36. package/dist/execution/watcher.js +0 -60
  37. package/dist/helpers/as.d.ts +0 -1
  38. package/dist/helpers/as.js +0 -6
  39. package/dist/helpers/debounce.d.ts +0 -1
  40. package/dist/helpers/debounce.js +0 -10
  41. package/dist/helpers/getConfig.d.ts +0 -1
  42. package/dist/helpers/getConfig.js +0 -26
  43. package/dist/helpers/getUserExecutors.d.ts +0 -2
  44. package/dist/helpers/getUserExecutors.js +0 -18
  45. package/dist/helpers/os.d.ts +0 -7
  46. package/dist/helpers/os.js +0 -8
  47. package/dist/helpers/utils.d.ts +0 -3
  48. package/dist/helpers/utils.js +0 -28
  49. package/dist/index.d.ts +0 -13
  50. package/dist/index.js +0 -41
  51. package/dist/lib/colors.d.ts +0 -3
  52. package/dist/lib/colors.js +0 -32
  53. package/dist/lib/currentModule.d.ts +0 -5
  54. package/dist/lib/currentModule.js +0 -19
  55. package/dist/local-env.d.ts +0 -4
  56. package/dist/local-env.js +0 -11
  57. package/dist/scriptExecutors/checkRuntime.d.ts +0 -2
  58. package/dist/scriptExecutors/checkRuntime.js +0 -56
  59. package/dist/scriptExecutors/helpers.d.ts +0 -3
  60. package/dist/scriptExecutors/helpers.js +0 -22
  61. package/dist/scriptExecutors/index.d.ts +0 -3
  62. package/dist/scriptExecutors/index.js +0 -313
  63. package/dist/scriptExecutors/types.t.d.ts +0 -17
  64. package/dist/scriptExecutors/types.t.js +0 -2
package/dist/argHelper.js DELETED
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.executionConfig = void 0;
7
- exports.mapFlagsToOptions = mapFlagsToOptions;
8
- const noarg_1 = __importDefault(require("noarg"));
9
- exports.executionConfig = noarg_1.default.defineConfig({
10
- flags: {
11
- 'do-not-watch': noarg_1.default.boolean()
12
- .aliases('dw')
13
- .description('Watch for file changes and reload the script'),
14
- 'disable-reload-key': noarg_1.default.boolean()
15
- .aliases('dk')
16
- .description("Disable 'Ctrl+R' or 'F5' to reload the script"),
17
- 'disable-raw-stdin': noarg_1.default.boolean()
18
- .aliases('drs')
19
- .description('Disable raw mode for stdin. Do not needed with `--disable-reload-key`'),
20
- exit: noarg_1.default.boolean().description('Do not watch the script. Just run it once and exit. Forced with `rux` or `uni-rux`'),
21
- silent: noarg_1.default.boolean()
22
- .aliases('s')
23
- .description('Do not show any output of the script'),
24
- keep: noarg_1.default.boolean()
25
- .aliases('k')
26
- .description('Do not clear the console while starting the script. Default with `rux` or `uni-rux`'),
27
- ext: noarg_1.default.array(noarg_1.default.string())
28
- .aliases('e')
29
- .description('Looks for changes only of the given extensions'),
30
- focus: noarg_1.default.array(noarg_1.default.string())
31
- .aliases('f')
32
- .description('Only watch the given items. `chokidar` syntax'),
33
- ignore: noarg_1.default.array(noarg_1.default.string())
34
- .aliases('ig')
35
- .description('Exclude the given items. `gitignore` syntax'),
36
- delay: noarg_1.default.number()
37
- .aliases('d')
38
- .default(100)
39
- .description('The delay to wait for the watcher to trigger'),
40
- bench: noarg_1.default.boolean()
41
- .aliases('b')
42
- .description('Calculate the execution time'),
43
- 'bench-prefix': noarg_1.default.string()
44
- .aliases('bp')
45
- .minLength(1)
46
- .description('The prefix to show before the execution time'),
47
- cwd: noarg_1.default.string()
48
- .default(process.cwd())
49
- .description('Set the current working directory'),
50
- env: noarg_1.default.array(noarg_1.default.string()).description('Set environment variables'),
51
- 'node-dev': noarg_1.default.boolean().description('Set env.NODE_ENV to "development"'),
52
- shell: noarg_1.default.boolean().description('Run script in shell for low-level commands'),
53
- info: noarg_1.default.boolean().description('Show information about the script'),
54
- time: noarg_1.default.boolean().description('Show the execution time at the start'),
55
- },
56
- listArgument: {
57
- name: 'args for script',
58
- description: 'The arguments to pass to the script',
59
- type: noarg_1.default.string(),
60
- },
61
- trailingArguments: '--',
62
- customRenderHelp: {
63
- helpUsageTrailingArgsLabel: '...[args/flags for script]',
64
- },
65
- });
66
- function mapFlagsToOptions(flags) {
67
- var _a, _b, _c, _d, _e;
68
- if (flags.exit) {
69
- flags['do-not-watch'] = true;
70
- flags['disable-reload-key'] = true;
71
- }
72
- return {
73
- cwd: flags.cwd,
74
- shell: !!flags.shell,
75
- silent: !!flags.silent,
76
- showInfo: !!flags.info,
77
- showTime: !!flags.time,
78
- benchmark: !!((_a = flags.bench) !== null && _a !== void 0 ? _a : flags['bench-prefix']),
79
- benchmarkPrefix: flags['bench-prefix'],
80
- clearOnReload: !flags.keep,
81
- keystrokeReload: !flags['disable-reload-key'],
82
- stdinSafeMode: !!flags['disable-raw-stdin'],
83
- watch: !flags['do-not-watch'],
84
- watchDelay: flags.delay,
85
- watchFocus: ((_b = flags.focus) === null || _b === void 0 ? void 0 : _b.length) ? flags.focus : [flags.cwd],
86
- watchIgnore: (_c = flags.ignore) !== null && _c !== void 0 ? _c : [],
87
- watchExtensions: (_d = flags.ext) !== null && _d !== void 0 ? _d : [],
88
- env: Object.assign(Object.assign({}, ((_e = flags.env) !== null && _e !== void 0 ? _e : []).reduce((acc, env) => {
89
- const [key, value] = env.split('=');
90
- acc[key] = value;
91
- return acc;
92
- }, {})), (flags['node-dev'] ? { NODE_ENV: 'development' } : {})),
93
- };
94
- }
package/dist/bin.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import './app';
package/dist/bin.js DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- require("./app");
5
- const arg_1 = require("./arg");
6
- arg_1.app.start();
package/dist/bix.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import './app';
package/dist/bix.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- require("./app");
5
- const arg_1 = require("./arg");
6
- const local_env_1 = require("./local-env");
7
- (0, local_env_1.setRuntime)('rux');
8
- arg_1.app.start();
@@ -1 +0,0 @@
1
- export default function (baseDir: string, extraIgnore?: string[]): import("ignore").Ignore;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.default = default_1;
30
- const fs = __importStar(require("fs"));
31
- const path = __importStar(require("path"));
32
- const ignore_1 = __importDefault(require("ignore"));
33
- function default_1(baseDir, extraIgnore = []) {
34
- const gitignorePath = path.resolve(path.join(baseDir, '.gitignore'));
35
- const ig = (0, ignore_1.default)({ ignorecase: true }).add(extraIgnore);
36
- if (fs.existsSync(gitignorePath)) {
37
- return ig.add(fs.readFileSync(gitignorePath).toString());
38
- }
39
- return ig;
40
- }
@@ -1,21 +0,0 @@
1
- import { ExecuteOptions } from '../argHelper';
2
- export default class Execution {
3
- private options;
4
- private startArgs;
5
- private preStartArgs?;
6
- private child;
7
- private benchMarkText;
8
- private isBenchmarkRunning;
9
- private isExecutionExecutedAnyTime;
10
- constructor(options: ExecuteOptions, startArgs: string[], preStartArgs?: string[] | undefined);
11
- start(): void;
12
- private spawnSync;
13
- private spawnAsync;
14
- private setup;
15
- private startProcess;
16
- private killProcess;
17
- private clearBeforeStart;
18
- private renderInfoLogs;
19
- private startBenchmark;
20
- private endBenchmark;
21
- }
@@ -1,177 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const readline = __importStar(require("readline"));
30
- const cross_spawn_1 = require("cross-spawn");
31
- const watcher_1 = __importDefault(require("./watcher"));
32
- const colors_1 = __importDefault(require("../lib/colors"));
33
- const kill_process_1 = __importDefault(require("./kill-process"));
34
- class Execution {
35
- constructor(options, startArgs, preStartArgs) {
36
- this.options = options;
37
- this.startArgs = startArgs;
38
- this.preStartArgs = preStartArgs;
39
- this.child = null;
40
- this.benchMarkText = colors_1.default.dim.green('# Execution time');
41
- this.isBenchmarkRunning = false;
42
- this.isExecutionExecutedAnyTime = false;
43
- this.setup();
44
- }
45
- start() {
46
- this.startProcess();
47
- }
48
- spawnSync(args) {
49
- const [command, ...args_] = args;
50
- return (0, cross_spawn_1.sync)(command, args_, {
51
- argv0: command,
52
- cwd: this.options.cwd,
53
- shell: this.options.shell,
54
- env: Object.assign(Object.assign({}, process.env), this.options.env),
55
- stdio: this.options.silent ? 'ignore' : 'inherit',
56
- });
57
- }
58
- spawnAsync(args) {
59
- const [command, ...args_] = args;
60
- return (0, cross_spawn_1.spawn)(command, args_, {
61
- argv0: command,
62
- cwd: this.options.cwd,
63
- shell: this.options.shell,
64
- env: Object.assign(Object.assign({}, process.env), this.options.env),
65
- stdio: this.options.silent ? 'ignore' : 'inherit',
66
- });
67
- }
68
- setup() {
69
- if (this.options.benchmarkPrefix) {
70
- this.benchMarkText =
71
- colors_1.default.bold(this.options.benchmarkPrefix) + ' ' + this.benchMarkText;
72
- }
73
- if (this.options.keystrokeReload) {
74
- readline.emitKeypressEvents(process.stdin);
75
- if (!this.options.stdinSafeMode) {
76
- process.stdin.setRawMode(true);
77
- }
78
- process.stdin.on('keypress', (_, key) => {
79
- if (key.name === 'f5' || (key.ctrl && key.name === 'r')) {
80
- return this.startProcess();
81
- }
82
- if (key.ctrl && key.name === 'c') {
83
- this.killProcess();
84
- process.exit(0);
85
- }
86
- });
87
- }
88
- if (this.options.watch) {
89
- (0, watcher_1.default)(this.options.cwd, this.options.watchFocus, () => this.startProcess(), {
90
- ignore: this.options.watchIgnore,
91
- debounceDelay: this.options.watchDelay,
92
- extensions: new Set(this.options.watchExtensions),
93
- });
94
- }
95
- }
96
- startProcess() {
97
- this.killProcess();
98
- this.clearBeforeStart();
99
- this.renderInfoLogs();
100
- this.isExecutionExecutedAnyTime = true;
101
- if (this.preStartArgs) {
102
- this.spawnSync(this.preStartArgs);
103
- }
104
- this.startBenchmark();
105
- this.child = this.spawnAsync(this.startArgs);
106
- this.child.on('exit', (code) => {
107
- this.endBenchmark();
108
- if (code && code > 0) {
109
- console.log(colors_1.default.red(`Process exited with code: ${colors_1.default.yellow(String(code))}`));
110
- }
111
- if (this.options.keystrokeReload) {
112
- console.log(colors_1.default.blue.dim(`> Press ${colors_1.default.yellow('F5')} or ${colors_1.default.yellow('^R')} to reload...`));
113
- }
114
- });
115
- }
116
- killProcess() {
117
- if (!this.child)
118
- return;
119
- this.child.removeAllListeners();
120
- const isKilled = (0, kill_process_1.default)(this.child);
121
- if (!isKilled) {
122
- console.error(colors_1.default.bgRed('ERROR:'), colors_1.default.red('Failed to kill the previous process'));
123
- }
124
- this.child = null;
125
- }
126
- clearBeforeStart() {
127
- if (this.options.clearOnReload) {
128
- process.stdout.write('\x1Bc');
129
- process.stdout.cursorTo(0, 0);
130
- process.stdout.clearScreenDown();
131
- console.clear();
132
- }
133
- }
134
- renderInfoLogs() {
135
- if (this.options.showInfo && !this.isExecutionExecutedAnyTime) {
136
- if (this.options.watch) {
137
- console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('Watching for extensions:'), colors_1.default.dim(this.options.watchExtensions
138
- .map((ext) => colors_1.default.reset(ext))
139
- .join(', ') || colors_1.default.yellow('*')));
140
- }
141
- if (this.options.watchFocus.length) {
142
- console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('Watching target:'), colors_1.default.dim(this.options.watchFocus
143
- .map((ext) => colors_1.default.reset(ext))
144
- .join(', ') || colors_1.default.yellow('*')));
145
- }
146
- if (this.options.watchIgnore.length) {
147
- console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('Watching ignore:'), colors_1.default.dim(this.options.watchIgnore
148
- .map((ext) => colors_1.default.reset(ext))
149
- .join(', ') || colors_1.default.yellow('*')));
150
- }
151
- if (this.options.shell) {
152
- console.log(colors_1.default.dim.bgGreen('INFO:'), colors_1.default.green('SHELL mode enabled'));
153
- }
154
- }
155
- if (this.options.showTime) {
156
- console.log(colors_1.default.dim.bgGreen('TIME:'), colors_1.default.green(new Date().toLocaleString()));
157
- }
158
- }
159
- startBenchmark() {
160
- if (this.options.benchmark) {
161
- if (this.isBenchmarkRunning) {
162
- console.timeEnd(this.benchMarkText);
163
- }
164
- else {
165
- this.isBenchmarkRunning = true;
166
- }
167
- console.time(this.benchMarkText);
168
- }
169
- }
170
- endBenchmark() {
171
- if (this.isBenchmarkRunning) {
172
- console.timeEnd(this.benchMarkText);
173
- this.isBenchmarkRunning = false;
174
- }
175
- }
176
- }
177
- exports.default = Execution;
@@ -1,2 +0,0 @@
1
- import { ChildProcess } from 'child_process';
2
- export default function (child: ChildProcess): boolean;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.default = default_1;
27
- const os = __importStar(require("os"));
28
- const child_process_1 = require("child_process");
29
- function default_1(child) {
30
- if (!child.pid)
31
- return true;
32
- child.removeAllListeners();
33
- const isWindows = os.platform() === 'win32';
34
- try {
35
- if (isWindows) {
36
- (0, child_process_1.execSync)(`taskkill /pid ${child.pid} /T /F`, { stdio: 'ignore' });
37
- }
38
- else {
39
- process.kill(-child.pid, 'SIGKILL');
40
- }
41
- }
42
- catch (_a) { }
43
- try {
44
- process.kill(child.pid, 0);
45
- return false;
46
- }
47
- catch (error) {
48
- return true;
49
- }
50
- }
@@ -1,6 +0,0 @@
1
- export type WatcherOptions = {
2
- ignore: string[];
3
- extensions: Set<string>;
4
- debounceDelay: number;
5
- };
6
- export default function (cwd: string, targets: string | string[], callback: () => void, options: WatcherOptions): void;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.default = default_1;
30
- const path = __importStar(require("path"));
31
- const gitignore_1 = __importDefault(require("./gitignore"));
32
- const chokidar = __importStar(require("chokidar"));
33
- const debounce_1 = require("../helpers/debounce");
34
- function default_1(cwd, targets, callback, options) {
35
- const ig = (0, gitignore_1.default)(cwd, options.ignore);
36
- const debounce = (0, debounce_1.createDebounce)(options.debounceDelay);
37
- const watcher = chokidar.watch(targets, {
38
- ignored: (filePath) => {
39
- for (const target of targets) {
40
- const relativePath = path.relative(target, filePath);
41
- if (!relativePath)
42
- return false;
43
- if (ig.ignores(relativePath))
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
- }
50
- }
51
- return false;
52
- },
53
- interval: options.debounceDelay / 2,
54
- ignoreInitial: true,
55
- persistent: true,
56
- });
57
- watcher.on('add', () => debounce(() => callback()));
58
- watcher.on('change', () => debounce(() => callback()));
59
- watcher.on('unlink', () => debounce(() => callback()));
60
- }
@@ -1 +0,0 @@
1
- export default function <const T>(arg: T): T;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- function default_1(arg) {
5
- return arg;
6
- }
@@ -1 +0,0 @@
1
- export declare function createDebounce(delay: number): (fn: () => void) => void;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDebounce = createDebounce;
4
- function createDebounce(delay) {
5
- let debounceTimeout;
6
- return function (fn) {
7
- clearTimeout(debounceTimeout);
8
- debounceTimeout = setTimeout(() => fn(), delay);
9
- };
10
- }
@@ -1 +0,0 @@
1
- export default function (...extraDirs: string[]): any;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = default_1;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const utils_1 = require("./utils");
10
- function inner(...extraDirs) {
11
- const userPath = (0, utils_1.getUserPath)();
12
- if (!userPath)
13
- return;
14
- const configFile = (0, utils_1.getExistedFile)(...extraDirs.map((dir) => path_1.default.join(dir, '/.uni-run.json')), path_1.default.join(process.cwd(), '/.uni-run.json'), path_1.default.join(userPath, '/.uni-run.json'));
15
- if (!configFile)
16
- return;
17
- try {
18
- const config = fs_1.default.readFileSync(configFile, 'utf-8');
19
- return JSON.parse(config);
20
- }
21
- catch (_a) { }
22
- }
23
- function default_1(...extraDirs) {
24
- var _a;
25
- return (_a = inner(...extraDirs)) !== null && _a !== void 0 ? _a : {};
26
- }
@@ -1,2 +0,0 @@
1
- import { ScriptExecutorOptions } from '../scriptExecutors/types.t';
2
- export default function (...extraDirs: string[]): ScriptExecutorOptions[] | undefined;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = default_1;
7
- const path_1 = __importDefault(require("path"));
8
- const utils_1 = require("./utils");
9
- const EXECUTOR_CONFIG_FILE = '.uni-run.cjs';
10
- function default_1(...extraDirs) {
11
- const userPath = (0, utils_1.getUserPath)();
12
- if (!userPath)
13
- return;
14
- const configFile = (0, utils_1.getExistedFile)(...extraDirs.map((dir) => path_1.default.join(dir, EXECUTOR_CONFIG_FILE)), path_1.default.join(process.cwd(), EXECUTOR_CONFIG_FILE), path_1.default.join(userPath, EXECUTOR_CONFIG_FILE));
15
- if (!configFile)
16
- return;
17
- return require(configFile);
18
- }
@@ -1,7 +0,0 @@
1
- declare const _default: {
2
- isWindows: boolean;
3
- isLinux: boolean;
4
- isMac: boolean;
5
- isUnix: boolean;
6
- };
7
- export default _default;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- isWindows: process.platform === 'win32',
5
- isLinux: process.platform === 'linux',
6
- isMac: process.platform === 'darwin',
7
- isUnix: process.platform === 'linux' || process.platform === 'darwin',
8
- };
@@ -1,3 +0,0 @@
1
- export declare function getExistedFile(...files: string[]): string | undefined;
2
- export declare function getUserPath(): string | undefined;
3
- export declare function emptyDir(...paths: string[]): string;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getExistedFile = getExistedFile;
7
- exports.getUserPath = getUserPath;
8
- exports.emptyDir = emptyDir;
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = __importDefault(require("path"));
11
- function getExistedFile(...files) {
12
- for (const file of files) {
13
- if (fs_1.default.existsSync(file))
14
- return file;
15
- }
16
- }
17
- function getUserPath() {
18
- var _a;
19
- return (_a = process.env.HOME) !== null && _a !== void 0 ? _a : process.env.USERPROFILE;
20
- }
21
- function emptyDir(...paths) {
22
- const target = path_1.default.join(...paths);
23
- if (fs_1.default.existsSync(target)) {
24
- fs_1.default.rmSync(target, { recursive: true, force: true });
25
- }
26
- fs_1.default.mkdirSync(target, { recursive: true });
27
- return target;
28
- }
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import './app';
2
- import getConfig from './helpers/getConfig';
3
- import currentModule from './lib/currentModule';
4
- import getUserExecutors from './helpers/getUserExecutors';
5
- import { ScriptExecutorOptions } from './scriptExecutors/types.t';
6
- export { currentModule, getConfig, getUserExecutors };
7
- export * from './scriptExecutors/types.t';
8
- declare const _default: {
9
- addExecutorBefore(executor: ScriptExecutorOptions): void;
10
- addExecutorAfter(executor: ScriptExecutorOptions): void;
11
- start(args?: string[]): void;
12
- };
13
- export default _default;