uni-run 1.0.4 → 1.0.6

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 (61) hide show
  1. package/README.md +122 -0
  2. package/dist/app.cjs +60 -0
  3. package/dist/app.d.mts +1 -0
  4. package/dist/{index.js → app.mjs} +8 -10
  5. package/dist/{arg-helper.js → arg-helper.cjs} +44 -31
  6. package/dist/{arg-helper.d.ts → arg-helper.d.cts} +52 -42
  7. package/dist/arg-helper.d.mts +121 -0
  8. package/dist/arg-helper.mjs +93 -0
  9. package/dist/{arg.js → arg.cjs} +5 -2
  10. package/dist/{arg.d.ts → arg.d.cts} +95 -77
  11. package/dist/arg.d.mts +243 -0
  12. package/dist/arg.mjs +9 -0
  13. package/dist/{bin.js → bin.cjs} +2 -2
  14. package/dist/{bin.d.ts → bin.d.cts} +1 -1
  15. package/dist/bin.d.mts +2 -0
  16. package/dist/bin.mjs +4 -0
  17. package/dist/builtin-bin/{Executor.js → Executor.cjs} +5 -2
  18. package/dist/builtin-bin/{Executor.d.ts → Executor.d.cts} +1 -1
  19. package/dist/builtin-bin/Executor.d.mts +21 -0
  20. package/dist/builtin-bin/Executor.mjs +61 -0
  21. package/dist/builtin-bin/{index.js → index.cjs} +4 -1
  22. package/dist/builtin-bin/{index.d.ts → index.d.cts} +1 -1
  23. package/dist/builtin-bin/index.d.mts +3 -0
  24. package/dist/builtin-bin/index.mjs +94 -0
  25. package/dist/execution/gitignore.cjs +40 -0
  26. package/dist/execution/gitignore.d.mts +1 -0
  27. package/dist/execution/gitignore.mjs +11 -0
  28. package/dist/execution/{index.js → index.cjs} +47 -8
  29. package/dist/execution/{index.d.ts → index.d.cts} +3 -1
  30. package/dist/execution/index.d.mts +15 -0
  31. package/dist/execution/index.mjs +103 -0
  32. package/dist/execution/kill-process.cjs +50 -0
  33. package/dist/execution/{kill-process.d.ts → kill-process.d.cts} +1 -1
  34. package/dist/execution/kill-process.d.mts +2 -0
  35. package/dist/execution/{kill-process.js → kill-process.mjs} +4 -7
  36. package/dist/execution/watcher.cjs +64 -0
  37. package/dist/execution/watcher.d.mts +6 -0
  38. package/dist/execution/{watcher.js → watcher.mjs} +8 -11
  39. package/dist/index.cjs +19 -0
  40. package/dist/index.d.cts +8 -0
  41. package/dist/index.d.mts +8 -0
  42. package/dist/index.mjs +13 -0
  43. package/dist/lib/colors.cjs +32 -0
  44. package/dist/lib/colors.d.cts +3 -0
  45. package/dist/lib/colors.d.mts +3 -0
  46. package/dist/lib/colors.mjs +4 -0
  47. package/dist/lib/currentModule.cjs +19 -0
  48. package/dist/lib/currentModule.d.cts +5 -0
  49. package/dist/lib/currentModule.d.mts +5 -0
  50. package/dist/lib/currentModule.mjs +17 -0
  51. package/dist/utils/debounce.d.mts +1 -0
  52. package/dist/utils/debounce.mjs +7 -0
  53. package/package.json +14 -10
  54. package/dist/execution/gitignore.js +0 -14
  55. package/dist/lib/colors.d.ts +0 -2
  56. package/dist/lib/colors.js +0 -4
  57. /package/dist/{index.d.ts → app.d.cts} +0 -0
  58. /package/dist/execution/{gitignore.d.ts → gitignore.d.cts} +0 -0
  59. /package/dist/execution/{watcher.d.ts → watcher.d.cts} +0 -0
  60. /package/dist/utils/{debounce.js → debounce.cjs} +0 -0
  61. /package/dist/utils/{debounce.d.ts → debounce.d.cts} +0 -0
@@ -0,0 +1,94 @@
1
+ import Executor from "./Executor.mjs";
2
+ export default [
3
+ new Executor('Node.js', {
4
+ extensions: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
5
+ checkInstallation: ['node', '--version'],
6
+ installMessage: 'Please install Node.js from https://nodejs.org',
7
+ run(args) {
8
+ return ['node', ...args];
9
+ },
10
+ }),
11
+ new Executor('TypeScript', {
12
+ extensions: ['ts', 'tsx', 'cts', 'ctsx', 'mts', 'mtsx'],
13
+ watchExtensions: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
14
+ checkInstallation(options) {
15
+ return options.tsNode ? ['ts-node', '--version'] : ['tsx', '--version'];
16
+ },
17
+ installCommands(options) {
18
+ return options.tsNode
19
+ ? ['npm install -g ts-node']
20
+ : ['npm install -g tsx'];
21
+ },
22
+ installMessage: 'Please install tsx. More: https://tsx.is',
23
+ run(args, options) {
24
+ return options.tsNode ? ['ts-node', ...args] : ['tsx', ...args];
25
+ },
26
+ }),
27
+ new Executor('Python', {
28
+ extensions: ['py'],
29
+ checkInstallation: ['python', '--version'],
30
+ installMessage: 'Please install Python from https://www.python.org',
31
+ run(args) {
32
+ return ['python', ...args];
33
+ },
34
+ }),
35
+ new Executor('Java - Oracle', {
36
+ extensions: ['java'],
37
+ checkInstallation: ['java', '--version'],
38
+ installMessage: 'Please install Java from https://www.oracle.com/java',
39
+ run(args) {
40
+ return ['java', ...args];
41
+ },
42
+ }),
43
+ new Executor('Powershell', {
44
+ extensions: ['ps1'],
45
+ checkInstallation: ['powershell', '-command', 'echo ok'],
46
+ installMessage: 'Please install Powershell from https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell',
47
+ run(args) {
48
+ return ['powershell', '-File', ...args];
49
+ },
50
+ }),
51
+ new Executor('Command Prompt', {
52
+ extensions: ['cmd', 'bat'],
53
+ checkInstallation: ['cmd', '/c', 'echo ok'],
54
+ installMessage: 'Please install Command Prompt from Windows',
55
+ run(args) {
56
+ return ['cmd', '/c', ...args];
57
+ },
58
+ }),
59
+ new Executor('Shell', {
60
+ extensions: ['sh'],
61
+ checkInstallation: ['bash', '--version'],
62
+ installMessage: 'Please install Bash from https://www.gnu.org/software/bash',
63
+ run(args) {
64
+ return ['bash', ...args];
65
+ },
66
+ }),
67
+ new Executor('Lua', {
68
+ extensions: ['lua'],
69
+ checkInstallation: ['lua', '--version'],
70
+ installMessage: 'Please install Lua from https://www.lua.org',
71
+ run(args) {
72
+ return ['lua', ...args];
73
+ },
74
+ }),
75
+ new Executor('SASS (CSS)', {
76
+ extensions: ['sass', 'scss'],
77
+ checkInstallation: ['sass', '--version'],
78
+ installCommands: ['npm install -g sass'],
79
+ installMessage: 'Please install SASS from https://sass-lang.com',
80
+ run(args) {
81
+ return ['sass', ...args];
82
+ },
83
+ }),
84
+ new Executor('HTML Server', {
85
+ extensions: ['html', 'htm'],
86
+ watchExtensions: ['css', 'js', 'javascript', 'json'],
87
+ checkInstallation: ['http-server', '--version'],
88
+ installCommands: ['npm install -g http-server'],
89
+ installMessage: 'Please install http-server from https://www.npmjs.com/package/http-server',
90
+ run(args) {
91
+ return ['http-server', ...args];
92
+ },
93
+ }),
94
+ ];
@@ -0,0 +1,40 @@
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
+ }
@@ -0,0 +1 @@
1
+ export default function (baseDir: string, extraIgnore?: string[]): import("ignore").Ignore;
@@ -0,0 +1,11 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import ignore from "ignore";
4
+ export default function (baseDir, extraIgnore = []) {
5
+ const gitignorePath = path.resolve(path.join(baseDir, '.gitignore'));
6
+ const ig = ignore({ ignorecase: true }).add(extraIgnore);
7
+ if (fs.existsSync(gitignorePath)) {
8
+ return ig.add(fs.readFileSync(gitignorePath).toString());
9
+ }
10
+ return ig;
11
+ }
@@ -1,10 +1,36 @@
1
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
+ };
2
28
  Object.defineProperty(exports, "__esModule", { value: true });
3
29
  const cross_spawn_1 = require("cross-spawn");
4
- const readline = require("readline");
5
- const watcher_1 = require("./watcher");
6
- const colors_1 = require("../lib/colors");
7
- const kill_process_1 = require("./kill-process");
30
+ const readline = __importStar(require("readline"));
31
+ const watcher_1 = __importDefault(require("./watcher.cjs"));
32
+ const colors_1 = __importDefault(require("../lib/colors.cjs"));
33
+ const kill_process_1 = __importDefault(require("./kill-process.cjs"));
8
34
  class Execution {
9
35
  static start([command, ...args], options) {
10
36
  return new Execution(command, args, options);
@@ -14,12 +40,18 @@ class Execution {
14
40
  this.args = args;
15
41
  this.options = options;
16
42
  this.child = null;
43
+ this.benchMarkText = colors_1.default.dim.blue('> Execution time');
44
+ this.isBenchmarkRunning = false;
17
45
  this.setup();
18
46
  this.runProcess();
19
47
  }
20
48
  setup() {
21
49
  var _a, _b;
22
- if (this.options.readlineReload) {
50
+ if (this.options.benchmarkPrefix) {
51
+ this.benchMarkText =
52
+ colors_1.default.bold(this.options.benchmarkPrefix) + ' ' + this.benchMarkText;
53
+ }
54
+ if (this.options.keystrokeReload) {
23
55
  readline.emitKeypressEvents(process.stdin);
24
56
  (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
25
57
  process.stdin.on('keypress', (_, key) => {
@@ -47,7 +79,13 @@ class Execution {
47
79
  console.log('@', colors_1.default.yellow(new Date().toLocaleString()));
48
80
  }
49
81
  if (this.options.benchmark) {
50
- console.time(colors_1.default.dim.blue('> Execution time'));
82
+ if (this.isBenchmarkRunning) {
83
+ console.timeEnd(this.benchMarkText);
84
+ }
85
+ else {
86
+ this.isBenchmarkRunning = true;
87
+ }
88
+ console.time(this.benchMarkText);
51
89
  }
52
90
  this.child = (0, cross_spawn_1.spawn)(this.command, this.args, {
53
91
  stdio: 'inherit',
@@ -62,14 +100,15 @@ class Execution {
62
100
  console.log(colors_1.default.red(`Process exited with code: ${colors_1.default.yellow(String(code))}`));
63
101
  }
64
102
  if (this.options.benchmark) {
65
- console.timeEnd(colors_1.default.dim.blue('> Execution time'));
103
+ this.isBenchmarkRunning = false;
104
+ console.timeEnd(this.benchMarkText);
66
105
  }
67
106
  if (this.options.watch && this.options.showInfo) {
68
107
  console.log(colors_1.default.dim.blue('> Watching for extensions:'), colors_1.default.dim(this.options.watchExtensions
69
108
  .map((ext) => colors_1.default.yellow(ext))
70
109
  .join(', ') || colors_1.default.yellow('*')));
71
110
  }
72
- if (this.options.readlineReload) {
111
+ if (this.options.keystrokeReload) {
73
112
  console.log(colors_1.default.blue.dim(`> Press ${colors_1.default.yellow('F5')} or ${colors_1.default.yellow('^R')} to reload...`));
74
113
  }
75
114
  });
@@ -1,9 +1,11 @@
1
- import { ExecuteOptions } from '../arg-helper';
1
+ import { ExecuteOptions } from "../arg-helper.cjs";
2
2
  export default class Execution {
3
3
  private command;
4
4
  private args;
5
5
  private options;
6
6
  private child;
7
+ private benchMarkText;
8
+ private isBenchmarkRunning;
7
9
  static start([command, ...args]: string[], options: ExecuteOptions): Execution;
8
10
  constructor(command: string, args: string[], options: ExecuteOptions);
9
11
  private setup;
@@ -0,0 +1,15 @@
1
+ import { ExecuteOptions } from "../arg-helper.mjs";
2
+ export default class Execution {
3
+ private command;
4
+ private args;
5
+ private options;
6
+ private child;
7
+ private benchMarkText;
8
+ private isBenchmarkRunning;
9
+ static start([command, ...args]: string[], options: ExecuteOptions): Execution;
10
+ constructor(command: string, args: string[], options: ExecuteOptions);
11
+ private setup;
12
+ private runProcess;
13
+ private killProcess;
14
+ private clearBeforeStart;
15
+ }
@@ -0,0 +1,103 @@
1
+ import { spawn } from "cross-spawn";
2
+ import * as readline from "readline";
3
+ import watcher from "./watcher.mjs";
4
+ import colors from "../lib/colors.mjs";
5
+ import killProcess from "./kill-process.mjs";
6
+ export default class Execution {
7
+ static start([command, ...args], options) {
8
+ return new Execution(command, args, options);
9
+ }
10
+ constructor(command, args, options) {
11
+ this.command = command;
12
+ this.args = args;
13
+ this.options = options;
14
+ this.child = null;
15
+ this.benchMarkText = colors.dim.blue('> Execution time');
16
+ this.isBenchmarkRunning = false;
17
+ this.setup();
18
+ this.runProcess();
19
+ }
20
+ setup() {
21
+ var _a, _b;
22
+ if (this.options.benchmarkPrefix) {
23
+ this.benchMarkText =
24
+ colors.bold(this.options.benchmarkPrefix) + ' ' + this.benchMarkText;
25
+ }
26
+ if (this.options.keystrokeReload) {
27
+ readline.emitKeypressEvents(process.stdin);
28
+ (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
29
+ process.stdin.on('keypress', (_, key) => {
30
+ if (key.name === 'f5' || (key.ctrl && key.name === 'r')) {
31
+ return this.runProcess();
32
+ }
33
+ if (key.ctrl && key.name === 'c') {
34
+ this.killProcess();
35
+ return process.exit(0);
36
+ }
37
+ });
38
+ }
39
+ if (this.options.watch) {
40
+ watcher(this.options.cwd, {
41
+ ignore: this.options.watchIgnore,
42
+ debounceDelay: this.options.watchDelay,
43
+ extensions: new Set(this.options.watchExtensions),
44
+ }, () => this.runProcess());
45
+ }
46
+ }
47
+ runProcess() {
48
+ this.killProcess();
49
+ this.clearBeforeStart();
50
+ if (this.options.showTime) {
51
+ console.log('@', colors.yellow(new Date().toLocaleString()));
52
+ }
53
+ if (this.options.benchmark) {
54
+ if (this.isBenchmarkRunning) {
55
+ console.timeEnd(this.benchMarkText);
56
+ }
57
+ else {
58
+ this.isBenchmarkRunning = true;
59
+ }
60
+ console.time(this.benchMarkText);
61
+ }
62
+ this.child = spawn(this.command, this.args, {
63
+ stdio: 'inherit',
64
+ argv0: this.command,
65
+ cwd: this.options.cwd,
66
+ shell: this.options.shell,
67
+ env: Object.assign({}, this.options.env),
68
+ });
69
+ this.child.on('error', console.error);
70
+ this.child.on('exit', (code) => {
71
+ if (code && code > 0) {
72
+ console.log(colors.red(`Process exited with code: ${colors.yellow(String(code))}`));
73
+ }
74
+ if (this.options.benchmark) {
75
+ this.isBenchmarkRunning = false;
76
+ console.timeEnd(this.benchMarkText);
77
+ }
78
+ if (this.options.watch && this.options.showInfo) {
79
+ console.log(colors.dim.blue('> Watching for extensions:'), colors.dim(this.options.watchExtensions
80
+ .map((ext) => colors.yellow(ext))
81
+ .join(', ') || colors.yellow('*')));
82
+ }
83
+ if (this.options.keystrokeReload) {
84
+ console.log(colors.blue.dim(`> Press ${colors.yellow('F5')} or ${colors.yellow('^R')} to reload...`));
85
+ }
86
+ });
87
+ }
88
+ killProcess() {
89
+ if (!this.child)
90
+ return;
91
+ this.child.removeAllListeners();
92
+ if (!killProcess(this.child)) {
93
+ console.error(colors.red('Failed to kill the previous process'));
94
+ }
95
+ this.child = null;
96
+ }
97
+ clearBeforeStart() {
98
+ if (this.options.clearOnReload) {
99
+ process.stdout.write('\x1Bc');
100
+ console.clear();
101
+ }
102
+ }
103
+ }
@@ -0,0 +1,50 @@
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,2 +1,2 @@
1
- import { ChildProcess } from 'child_process';
1
+ import { ChildProcess } from "child_process";
2
2
  export default function (child: ChildProcess): boolean;
@@ -0,0 +1,2 @@
1
+ import { ChildProcess } from "child_process";
2
+ export default function (child: ChildProcess): boolean;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const os = require("os");
5
- const child_process_1 = require("child_process");
6
- function default_1(child) {
1
+ import * as os from "os";
2
+ import { execSync } from "child_process";
3
+ export default function (child) {
7
4
  if (!child.pid)
8
5
  return true;
9
6
  child.removeAllListeners();
10
7
  const isWindows = os.platform() === 'win32';
11
8
  try {
12
9
  if (isWindows) {
13
- (0, child_process_1.execSync)(`taskkill /pid ${child.pid} /T /F`, { stdio: 'ignore' });
10
+ execSync(`taskkill /pid ${child.pid} /T /F`, { stdio: 'ignore' });
14
11
  }
15
12
  else {
16
13
  process.kill(-child.pid, 'SIGKILL');
@@ -0,0 +1,64 @@
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.cjs"));
32
+ const chokidar = __importStar(require("chokidar"));
33
+ const debounce_1 = require("../utils/debounce.cjs");
34
+ function default_1(dir, options, callback) {
35
+ const ig = (0, gitignore_1.default)(dir, options.ignore);
36
+ const debounce = (0, debounce_1.createDebounce)(options.debounceDelay);
37
+ const watcher = chokidar.watch(dir, {
38
+ ignored: (filePath) => {
39
+ const relativePath = path.relative(dir, filePath);
40
+ if (!relativePath)
41
+ return false;
42
+ if (ig.ignores(relativePath))
43
+ return true;
44
+ if (options.extensions.size) {
45
+ const ext = path.extname(relativePath).slice(1);
46
+ if (ext && !options.extensions.has(ext))
47
+ return true;
48
+ }
49
+ return false;
50
+ },
51
+ interval: options.debounceDelay / 2,
52
+ ignoreInitial: true,
53
+ persistent: true,
54
+ });
55
+ watcher.on('add', (event) => {
56
+ debounce(() => callback());
57
+ });
58
+ watcher.on('change', (event) => {
59
+ debounce(() => callback());
60
+ });
61
+ watcher.on('unlink', () => {
62
+ debounce(() => callback());
63
+ });
64
+ }
@@ -0,0 +1,6 @@
1
+ export type WatcherOptions = {
2
+ ignore: string[];
3
+ extensions: Set<string>;
4
+ debounceDelay: number;
5
+ };
6
+ export default function (dir: string, options: WatcherOptions, callback: () => void): void;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const path = require("path");
5
- const chokidar = require("chokidar");
6
- const gitignore_1 = require("./gitignore");
7
- const debounce_1 = require("../utils/debounce");
8
- function default_1(dir, options, callback) {
9
- const ig = (0, gitignore_1.default)(dir, options.ignore);
10
- const debounce = (0, debounce_1.createDebounce)(options.debounceDelay);
1
+ import * as path from "path";
2
+ import gitignore from "./gitignore.mjs";
3
+ import * as chokidar from "chokidar";
4
+ import { createDebounce } from "../utils/debounce.mjs";
5
+ export default function (dir, options, callback) {
6
+ const ig = gitignore(dir, options.ignore);
7
+ const debounce = createDebounce(options.debounceDelay);
11
8
  const watcher = chokidar.watch(dir, {
12
9
  ignored: (filePath) => {
13
10
  const relativePath = path.relative(dir, filePath);
@@ -23,8 +20,8 @@ function default_1(dir, options, callback) {
23
20
  return false;
24
21
  },
25
22
  interval: options.debounceDelay / 2,
26
- persistent: true,
27
23
  ignoreInitial: true,
24
+ persistent: true,
28
25
  });
29
26
  watcher.on('add', (event) => {
30
27
  debounce(() => callback());
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
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.Executor = void 0;
7
+ require("./app.cjs");
8
+ const arg_1 = require("./arg.cjs");
9
+ const builtin_bin_1 = __importDefault(require("./builtin-bin/index.cjs"));
10
+ const Executor_1 = __importDefault(require("./builtin-bin/Executor.cjs"));
11
+ exports.Executor = Executor_1.default;
12
+ exports.default = {
13
+ addBin(bin) {
14
+ builtin_bin_1.default.push(bin);
15
+ },
16
+ start(args) {
17
+ arg_1.app.start(args);
18
+ },
19
+ };
@@ -0,0 +1,8 @@
1
+ import "./app.cjs";
2
+ import Executor from "./builtin-bin/Executor.cjs";
3
+ export { Executor };
4
+ declare const _default: {
5
+ addBin(bin: Executor): void;
6
+ start(args?: string[]): void;
7
+ };
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import "./app.mjs";
2
+ import Executor from "./builtin-bin/Executor.mjs";
3
+ export { Executor };
4
+ declare const _default: {
5
+ addBin(bin: Executor): void;
6
+ start(args?: string[]): void;
7
+ };
8
+ export default _default;
package/dist/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ import "./app.mjs";
2
+ import { app } from "./arg.mjs";
3
+ import builtinBin from "./builtin-bin/index.mjs";
4
+ import Executor from "./builtin-bin/Executor.mjs";
5
+ export { Executor };
6
+ export default {
7
+ addBin(bin) {
8
+ builtinBin.push(bin);
9
+ },
10
+ start(args) {
11
+ app.start(args);
12
+ },
13
+ };
@@ -0,0 +1,32 @@
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 ansi_colors_1 = __importDefault(require("ansi-colors"));
30
+ const cjs = __importStar(require("ansi-colors"));
31
+ const currentModule_1 = __importDefault(require("./currentModule.cjs"));
32
+ exports.default = currentModule_1.default.isCJS ? cjs : ansi_colors_1.default;
@@ -0,0 +1,3 @@
1
+ import mjs from "ansi-colors";
2
+ declare const _default: typeof mjs;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import mjs from "ansi-colors";
2
+ declare const _default: typeof mjs;
3
+ export default _default;