concurrently 9.2.1 → 10.0.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/README.md +25 -14
- package/dist/bin/bin-options.d.ts +1 -0
- package/dist/bin/bin-options.js +1 -0
- package/dist/bin/{concurrently.js → index.js} +23 -62
- package/dist/bin/normalize-cli-command.d.ts +1 -0
- package/dist/bin/normalize-cli-command.js +15 -0
- package/dist/bin/read-package-json.d.ts +4 -0
- package/dist/bin/read-package-json.js +17 -0
- package/dist/lib/assert.d.ts +10 -0
- package/dist/lib/assert.js +24 -0
- package/dist/{src → lib}/command-parser/expand-arguments.d.ts +2 -2
- package/dist/{src → lib}/command-parser/expand-arguments.js +7 -12
- package/dist/{src → lib}/command-parser/expand-shortcut.d.ts +2 -2
- package/dist/{src → lib}/command-parser/expand-shortcut.js +1 -5
- package/dist/{src → lib}/command-parser/expand-wildcard.d.ts +2 -2
- package/dist/{src → lib}/command-parser/expand-wildcard.js +21 -28
- package/dist/{src → lib}/command.d.ts +5 -4
- package/dist/{src → lib}/command.js +3 -39
- package/dist/{src → lib}/completion-listener.d.ts +2 -2
- package/dist/{src → lib}/completion-listener.js +9 -46
- package/dist/{src → lib}/concurrently.d.ts +10 -10
- package/dist/{src → lib}/concurrently.js +29 -40
- package/dist/{src → lib}/date-format.d.ts +2 -2
- package/dist/{src → lib}/date-format.js +97 -76
- package/dist/{src → lib}/defaults.d.ts +2 -6
- package/dist/{src → lib}/defaults.js +16 -23
- package/dist/{src → lib}/flow-control/flow-controller.d.ts +1 -1
- package/dist/lib/flow-control/flow-controller.js +1 -0
- package/dist/{src → lib}/flow-control/input-handler.d.ts +4 -4
- package/dist/{src → lib}/flow-control/input-handler.js +8 -44
- package/dist/{src → lib}/flow-control/kill-on-signal.d.ts +3 -3
- package/dist/{src → lib}/flow-control/kill-on-signal.js +3 -7
- package/dist/{src → lib}/flow-control/kill-others.d.ts +3 -3
- package/dist/{src → lib}/flow-control/kill-others.js +8 -12
- package/dist/{src → lib}/flow-control/log-error.d.ts +3 -3
- package/dist/{src → lib}/flow-control/log-error.js +1 -5
- package/dist/{src → lib}/flow-control/log-exit.d.ts +3 -3
- package/dist/{src → lib}/flow-control/log-exit.js +1 -5
- package/dist/{src → lib}/flow-control/log-output.d.ts +3 -3
- package/dist/{src → lib}/flow-control/log-output.js +1 -5
- package/dist/{src → lib}/flow-control/log-timings.d.ts +3 -3
- package/dist/{src → lib}/flow-control/log-timings.js +8 -45
- package/dist/{src → lib}/flow-control/logger-padding.d.ts +3 -3
- package/dist/{src → lib}/flow-control/logger-padding.js +7 -7
- package/dist/{src → lib}/flow-control/output-error-handler.d.ts +4 -4
- package/dist/{src → lib}/flow-control/output-error-handler.js +3 -7
- package/dist/{src → lib}/flow-control/restart-process.d.ts +4 -4
- package/dist/lib/flow-control/restart-process.js +61 -0
- package/dist/{src → lib}/flow-control/teardown.d.ts +4 -5
- package/dist/lib/flow-control/teardown.js +45 -0
- package/dist/{src → lib}/index.d.ts +21 -19
- package/dist/lib/index.js +98 -0
- package/dist/{src → lib}/jsonc.js +3 -8
- package/dist/{src → lib}/logger.d.ts +3 -2
- package/dist/{src → lib}/logger.js +109 -65
- package/dist/{src → lib}/observables.d.ts +1 -1
- package/dist/{src → lib}/observables.js +3 -6
- package/dist/{src → lib}/output-writer.d.ts +3 -3
- package/dist/{src → lib}/output-writer.js +4 -41
- package/dist/lib/prefix-color-selector.d.ts +21 -0
- package/dist/{src → lib}/prefix-color-selector.js +14 -31
- package/dist/{src → lib}/spawn.d.ts +14 -5
- package/dist/lib/spawn.js +105 -0
- package/dist/lib/utils.d.ts +25 -0
- package/dist/lib/utils.js +52 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/README.md +6 -0
- package/docs/cli/prefixing.md +44 -4
- package/docs/shell-resolution.md +48 -0
- package/package.json +48 -67
- package/dist/bin/read-package.d.ts +0 -6
- package/dist/bin/read-package.js +0 -56
- package/dist/src/assert.d.ts +0 -5
- package/dist/src/assert.js +0 -15
- package/dist/src/command-parser/command-parser.d.ts +0 -19
- package/dist/src/command-parser/command-parser.js +0 -2
- package/dist/src/command-parser/strip-quotes.d.ts +0 -16
- package/dist/src/command-parser/strip-quotes.js +0 -17
- package/dist/src/flow-control/flow-controller.js +0 -2
- package/dist/src/flow-control/restart-process.js +0 -98
- package/dist/src/flow-control/teardown.js +0 -82
- package/dist/src/index.js +0 -96
- package/dist/src/prefix-color-selector.d.ts +0 -11
- package/dist/src/spawn.js +0 -49
- package/dist/src/utils.d.ts +0 -10
- package/dist/src/utils.js +0 -16
- package/index.d.mts +0 -7
- package/index.d.ts +0 -11
- package/index.js +0 -14
- package/index.mjs +0 -9
- /package/dist/bin/{concurrently.d.ts → index.d.ts} +0 -0
- /package/dist/{src → lib}/jsonc.d.ts +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { assertNotRuntime } from './assert.js';
|
|
3
|
+
import { Command } from './command.js';
|
|
4
|
+
import { concurrently as createConcurrently, } from './concurrently.js';
|
|
5
|
+
import { InputHandler } from './flow-control/input-handler.js';
|
|
6
|
+
import { KillOnSignal } from './flow-control/kill-on-signal.js';
|
|
7
|
+
import { KillOthers } from './flow-control/kill-others.js';
|
|
8
|
+
import { LogError } from './flow-control/log-error.js';
|
|
9
|
+
import { LogExit } from './flow-control/log-exit.js';
|
|
10
|
+
import { LogOutput } from './flow-control/log-output.js';
|
|
11
|
+
import { LogTimings } from './flow-control/log-timings.js';
|
|
12
|
+
import { LoggerPadding } from './flow-control/logger-padding.js';
|
|
13
|
+
import { OutputErrorHandler } from './flow-control/output-error-handler.js';
|
|
14
|
+
import { RestartProcess } from './flow-control/restart-process.js';
|
|
15
|
+
import { Teardown } from './flow-control/teardown.js';
|
|
16
|
+
import { Logger } from './logger.js';
|
|
17
|
+
import { createSpawn } from './spawn.js';
|
|
18
|
+
import { castArray } from './utils.js';
|
|
19
|
+
export function concurrently(commands, options = {}) {
|
|
20
|
+
assertNotRuntime(
|
|
21
|
+
// When run via /snap/bin/node, process.execPath maps to the actual snap path, but it also sets
|
|
22
|
+
// several SNAP_* env variables. If the snap is run directly via e.g. /snap/node/current/bin/node,
|
|
23
|
+
// the issues don't happen and no env variables are set.
|
|
24
|
+
!String(process.env.SNAP).startsWith('/snap'), 'Snap', 'Snap confinement can interfere with spawning child processes. See issue #584');
|
|
25
|
+
// To avoid empty strings from hiding the output of commands that don't have a name,
|
|
26
|
+
// keep in the list of commands to hide only strings with some length.
|
|
27
|
+
// This might happen through the CLI when no `--hide` argument is specified, for example.
|
|
28
|
+
const hide = castArray(options.hide).filter((id) => id || id === 0);
|
|
29
|
+
const logger = options.logger ||
|
|
30
|
+
new Logger({
|
|
31
|
+
hide,
|
|
32
|
+
prefixFormat: options.prefix,
|
|
33
|
+
commandLength: options.prefixLength,
|
|
34
|
+
raw: options.raw,
|
|
35
|
+
timestampFormat: options.timestampFormat,
|
|
36
|
+
});
|
|
37
|
+
if (options.prefixColors === false) {
|
|
38
|
+
logger.toggleColors(false);
|
|
39
|
+
}
|
|
40
|
+
const abortController = new AbortController();
|
|
41
|
+
const outputStream = options.outputStream || process.stdout;
|
|
42
|
+
const spawn = createSpawn(options.shell);
|
|
43
|
+
return createConcurrently(commands, {
|
|
44
|
+
maxProcesses: options.maxProcesses,
|
|
45
|
+
raw: options.raw,
|
|
46
|
+
successCondition: options.successCondition,
|
|
47
|
+
cwd: options.cwd,
|
|
48
|
+
spawn,
|
|
49
|
+
hide,
|
|
50
|
+
logger,
|
|
51
|
+
outputStream,
|
|
52
|
+
group: options.group,
|
|
53
|
+
abortSignal: abortController.signal,
|
|
54
|
+
controllers: [
|
|
55
|
+
// LoggerPadding needs to run before any other controllers that might output something
|
|
56
|
+
...(options.padPrefix ? [new LoggerPadding({ logger })] : []),
|
|
57
|
+
new LogError({ logger }),
|
|
58
|
+
new LogOutput({ logger }),
|
|
59
|
+
new LogExit({ logger }),
|
|
60
|
+
new InputHandler({
|
|
61
|
+
logger,
|
|
62
|
+
defaultInputTarget: options.defaultInputTarget,
|
|
63
|
+
inputStream: options.inputStream || (options.handleInput ? process.stdin : undefined),
|
|
64
|
+
pauseInputStreamOnFinish: options.pauseInputStreamOnFinish,
|
|
65
|
+
}),
|
|
66
|
+
new KillOnSignal({ process, abortController }),
|
|
67
|
+
new RestartProcess({
|
|
68
|
+
logger,
|
|
69
|
+
delay: options.restartDelay,
|
|
70
|
+
tries: options.restartTries,
|
|
71
|
+
}),
|
|
72
|
+
new KillOthers({
|
|
73
|
+
logger,
|
|
74
|
+
conditions: options.killOthersOn || [],
|
|
75
|
+
timeoutMs: options.killTimeout,
|
|
76
|
+
killSignal: options.killSignal,
|
|
77
|
+
abortController,
|
|
78
|
+
}),
|
|
79
|
+
new OutputErrorHandler({ abortController, outputStream }),
|
|
80
|
+
new LogTimings({
|
|
81
|
+
logger: options.timings ? logger : undefined,
|
|
82
|
+
timestampFormat: options.timestampFormat,
|
|
83
|
+
}),
|
|
84
|
+
new Teardown({ logger, spawn, commands: options.teardown || [] }),
|
|
85
|
+
],
|
|
86
|
+
prefixColors: options.prefixColors || [],
|
|
87
|
+
additionalArguments: options.additionalArguments,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Export all flow controllers, types, and the main concurrently function,
|
|
91
|
+
// so that 3rd-parties can use them however they want
|
|
92
|
+
// Main
|
|
93
|
+
export default concurrently;
|
|
94
|
+
export { createConcurrently, Logger };
|
|
95
|
+
// Command specific
|
|
96
|
+
export { Command };
|
|
97
|
+
// Flow controllers
|
|
98
|
+
export { InputHandler, KillOnSignal, KillOthers, LogError, LogExit, LogOutput, LogTimings, RestartProcess, };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
ORIGINAL https://www.npmjs.com/package/tiny-jsonc
|
|
4
3
|
BY Fabio Spampinato
|
|
@@ -6,11 +5,8 @@ MIT license
|
|
|
6
5
|
|
|
7
6
|
Copied due to the dependency not being compatible with CommonJS
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const stringOrCommentRe = /("(?:\\?[^])*?")|(\/\/.*)|(\/\*[^]*?\*\/)/g;
|
|
12
|
-
const stringOrTrailingCommaRe = /("(?:\\?[^])*?")|(,\s*)(?=]|})/g;
|
|
13
|
-
/* MAIN */
|
|
8
|
+
const stringOrCommentRe = /("(?:\\?[\s\S])*?")|(\/\/.*)|(\/\*[\s\S]*?\*\/)/g;
|
|
9
|
+
const stringOrTrailingCommaRe = /("(?:\\?[\s\S])*?")|(,\s*)(?=\]|\})/g;
|
|
14
10
|
const JSONC = {
|
|
15
11
|
parse: (text) => {
|
|
16
12
|
text = String(text); // To be extra safe
|
|
@@ -25,5 +21,4 @@ const JSONC = {
|
|
|
25
21
|
},
|
|
26
22
|
stringify: JSON.stringify,
|
|
27
23
|
};
|
|
28
|
-
|
|
29
|
-
exports.default = JSONC;
|
|
24
|
+
export default JSONC;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Command, CommandIdentifier } from './command';
|
|
1
|
+
import Rx from 'rxjs';
|
|
2
|
+
import { Command, CommandIdentifier } from './command.js';
|
|
3
|
+
export declare const COLOR_MARKER_RE: RegExp;
|
|
3
4
|
export declare class Logger {
|
|
4
5
|
private readonly hide;
|
|
5
6
|
private readonly raw;
|
|
@@ -1,55 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import chalk, { Chalk } from 'chalk';
|
|
2
|
+
import Rx from 'rxjs';
|
|
3
|
+
import { DateFormatter } from './date-format.js';
|
|
4
|
+
import * as defaults from './defaults.js';
|
|
5
|
+
import { escapeRegExp, splitOutsideParens } from './utils.js';
|
|
6
|
+
const defaultChalk = chalk;
|
|
7
|
+
const noColorChalk = new Chalk({ level: 0 });
|
|
8
|
+
const HEX_PATTERN = /^#[0-9A-Fa-f]{3,6}$/;
|
|
9
|
+
const COLOR_OPEN = '{color}';
|
|
10
|
+
const COLOR_CLOSE = '{/color}';
|
|
11
|
+
export const COLOR_MARKER_RE = /\{\/?color\}/g;
|
|
12
|
+
/**
|
|
13
|
+
* Applies a single color segment to a chalk instance.
|
|
14
|
+
* Handles: function calls (hex, bgHex, rgb, bgRgb, ansi256, bgAnsi256, etc.),
|
|
15
|
+
* shorthands (#HEX, bg#HEX), and named colors/modifiers.
|
|
16
|
+
*/
|
|
17
|
+
function applySegment(color, segment) {
|
|
18
|
+
// Function call: name(args) - handles chalk color functions
|
|
19
|
+
const fnMatch = segment.match(/^(\w+)\((.+)\)$/);
|
|
20
|
+
if (fnMatch) {
|
|
21
|
+
const [, fnName, argsStr] = fnMatch;
|
|
22
|
+
const args = argsStr.split(',').map((a) => {
|
|
23
|
+
const t = a.trim();
|
|
24
|
+
return /^\d+$/.test(t) ? parseInt(t, 10) : t;
|
|
25
|
+
});
|
|
26
|
+
// Explicit function calls for known chalk color functions
|
|
27
|
+
switch (fnName) {
|
|
28
|
+
case 'rgb':
|
|
29
|
+
return color.rgb(args[0], args[1], args[2]);
|
|
30
|
+
case 'bgRgb':
|
|
31
|
+
return color.bgRgb(args[0], args[1], args[2]);
|
|
32
|
+
case 'hex':
|
|
33
|
+
if (!HEX_PATTERN.test(args[0]))
|
|
34
|
+
return undefined;
|
|
35
|
+
return color.hex(args[0]);
|
|
36
|
+
case 'bgHex':
|
|
37
|
+
if (!HEX_PATTERN.test(args[0]))
|
|
38
|
+
return undefined;
|
|
39
|
+
return color.bgHex(args[0]);
|
|
40
|
+
case 'ansi256':
|
|
41
|
+
return color.ansi256(args[0]);
|
|
42
|
+
case 'bgAnsi256':
|
|
43
|
+
return color.bgAnsi256(args[0]);
|
|
44
|
+
default:
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
7
47
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Logger = void 0;
|
|
40
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
-
const Rx = __importStar(require("rxjs"));
|
|
42
|
-
const date_format_1 = require("./date-format");
|
|
43
|
-
const defaults = __importStar(require("./defaults"));
|
|
44
|
-
const utils_1 = require("./utils");
|
|
45
|
-
const defaultChalk = chalk_1.default;
|
|
46
|
-
const noColorChalk = new chalk_1.default.Instance({ level: 0 });
|
|
47
|
-
function getChalkPath(chalk, path) {
|
|
48
|
-
return path
|
|
49
|
-
.split('.')
|
|
50
|
-
.reduce((prev, key) => prev[key], chalk);
|
|
48
|
+
// Shorthands
|
|
49
|
+
if (segment.startsWith('bg#'))
|
|
50
|
+
return color.bgHex(segment.slice(2));
|
|
51
|
+
if (segment.startsWith('#'))
|
|
52
|
+
return color.hex(segment);
|
|
53
|
+
// Property: black, bold, dim, etc.
|
|
54
|
+
return color[segment] ?? undefined;
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Applies a color string to chalk, supporting chained colors and modifiers.
|
|
58
|
+
* Returns undefined if any segment is invalid (triggers fallback to default).
|
|
59
|
+
*/
|
|
60
|
+
function applyColor(chalkInstance, colorString) {
|
|
61
|
+
const segments = splitOutsideParens(colorString, '.');
|
|
62
|
+
if (segments.length === 0)
|
|
63
|
+
return undefined;
|
|
64
|
+
let color = chalkInstance;
|
|
65
|
+
for (const segment of segments) {
|
|
66
|
+
const next = applySegment(color, segment);
|
|
67
|
+
if (!next)
|
|
68
|
+
return undefined;
|
|
69
|
+
color = next;
|
|
70
|
+
}
|
|
71
|
+
return color;
|
|
72
|
+
}
|
|
73
|
+
export class Logger {
|
|
53
74
|
hide;
|
|
54
75
|
raw;
|
|
55
76
|
prefixFormat;
|
|
@@ -76,7 +97,7 @@ class Logger {
|
|
|
76
97
|
this.raw = raw;
|
|
77
98
|
this.prefixFormat = prefixFormat;
|
|
78
99
|
this.commandLength = commandLength || defaults.prefixLength;
|
|
79
|
-
this.dateFormatter = new
|
|
100
|
+
this.dateFormatter = new DateFormatter(timestampFormat || defaults.timestampFormat);
|
|
80
101
|
}
|
|
81
102
|
/**
|
|
82
103
|
* Toggles colors on/off globally.
|
|
@@ -117,7 +138,7 @@ class Logger {
|
|
|
117
138
|
return { type: 'default', value: prefixes[prefix] };
|
|
118
139
|
}
|
|
119
140
|
const value = Object.entries(prefixes).reduce((prev, [key, val]) => {
|
|
120
|
-
const keyRegex = new RegExp(
|
|
141
|
+
const keyRegex = new RegExp(escapeRegExp(`{${key}}`), 'g');
|
|
121
142
|
return prev.replace(keyRegex, String(val));
|
|
122
143
|
}, prefix);
|
|
123
144
|
return { type: 'template', value };
|
|
@@ -127,23 +148,47 @@ class Logger {
|
|
|
127
148
|
if (!content) {
|
|
128
149
|
return '';
|
|
129
150
|
}
|
|
151
|
+
const visibleLength = content.value.replace(COLOR_MARKER_RE, '').length;
|
|
152
|
+
const padding = ' '.repeat(Math.max(0, this.prefixLength - visibleLength));
|
|
130
153
|
return content.type === 'template'
|
|
131
|
-
? content.value
|
|
132
|
-
: `[${content.value
|
|
154
|
+
? content.value + padding
|
|
155
|
+
: `[${content.value}${padding}]`;
|
|
133
156
|
}
|
|
134
157
|
setPrefixLength(length) {
|
|
135
158
|
this.prefixLength = length;
|
|
136
159
|
}
|
|
137
160
|
colorText(command, text) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
161
|
+
const prefixColor = command.prefixColor ?? '';
|
|
162
|
+
const defaultColor = applyColor(this.chalk, defaults.prefixColors) ?? this.chalk.reset;
|
|
163
|
+
const color = applyColor(this.chalk, prefixColor) ?? defaultColor;
|
|
164
|
+
// Segment the text around `{color}` / `{/color}` markers and only apply `color`
|
|
165
|
+
// inside opened regions. If either marker is missing, it's implicitly added to
|
|
166
|
+
// the start or end respectively — so a marker-free input stays fully colored,
|
|
167
|
+
// preserving backward compatibility.
|
|
168
|
+
let normalized = text;
|
|
169
|
+
if (!normalized.includes(COLOR_OPEN))
|
|
170
|
+
normalized = COLOR_OPEN + normalized;
|
|
171
|
+
if (!normalized.includes(COLOR_CLOSE))
|
|
172
|
+
normalized = normalized + COLOR_CLOSE;
|
|
173
|
+
let output = '';
|
|
174
|
+
let rest = normalized;
|
|
175
|
+
let inColorRegion = false;
|
|
176
|
+
while (rest.length > 0) {
|
|
177
|
+
const marker = inColorRegion ? COLOR_CLOSE : COLOR_OPEN;
|
|
178
|
+
const idx = rest.indexOf(marker);
|
|
179
|
+
if (idx === -1) {
|
|
180
|
+
// Tail after the last closing marker: normalization guarantees a
|
|
181
|
+
// `{/color}` exists, so once opened a region always finds its close —
|
|
182
|
+
// reaching here implies `inColorRegion` is false and the tail is plain.
|
|
183
|
+
output += rest;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
const segment = rest.slice(0, idx);
|
|
187
|
+
output += inColorRegion ? color(segment) : segment;
|
|
188
|
+
rest = rest.slice(idx + marker.length);
|
|
189
|
+
inColorRegion = !inColorRegion;
|
|
145
190
|
}
|
|
146
|
-
return
|
|
191
|
+
return output;
|
|
147
192
|
}
|
|
148
193
|
/**
|
|
149
194
|
* Logs an event for a command (e.g. start, stop).
|
|
@@ -161,7 +206,7 @@ class Logger {
|
|
|
161
206
|
if (this.lastWrite?.command === command && this.lastWrite.char !== '\n') {
|
|
162
207
|
prefix = '\n';
|
|
163
208
|
}
|
|
164
|
-
this.logCommandText(prefix
|
|
209
|
+
this.logCommandText(`${prefix}${this.chalk.reset(text)}\n`, command);
|
|
165
210
|
}
|
|
166
211
|
logCommandText(text, command) {
|
|
167
212
|
if (this.hide.includes(String(command.index)) || this.hide.includes(command.name)) {
|
|
@@ -179,7 +224,7 @@ class Logger {
|
|
|
179
224
|
if (this.raw) {
|
|
180
225
|
return;
|
|
181
226
|
}
|
|
182
|
-
this.log(this.chalk.reset('-->')
|
|
227
|
+
this.log(`${this.chalk.reset('-->')} `, `${this.chalk.reset(text)}\n`);
|
|
183
228
|
}
|
|
184
229
|
/**
|
|
185
230
|
* Logs a table from an input object array, like `console.table`.
|
|
@@ -253,4 +298,3 @@ class Logger {
|
|
|
253
298
|
this.output.next({ command, text });
|
|
254
299
|
}
|
|
255
300
|
}
|
|
256
|
-
exports.Logger = Logger;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fromSharedEvent = fromSharedEvent;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
1
|
+
import { fromEvent, share } from 'rxjs';
|
|
5
2
|
const sharedEvents = new WeakMap();
|
|
6
3
|
/**
|
|
7
4
|
* Creates an observable for a specific event of an `EventEmitter` instance.
|
|
8
5
|
*
|
|
9
6
|
* The underlying event listener is set up only once across the application for that event emitter/name pair.
|
|
10
7
|
*/
|
|
11
|
-
function fromSharedEvent(emitter, event) {
|
|
8
|
+
export function fromSharedEvent(emitter, event) {
|
|
12
9
|
let emitterEvents = sharedEvents.get(emitter);
|
|
13
10
|
if (!emitterEvents) {
|
|
14
11
|
emitterEvents = new Map();
|
|
@@ -16,7 +13,7 @@ function fromSharedEvent(emitter, event) {
|
|
|
16
13
|
}
|
|
17
14
|
let observable = emitterEvents.get(event);
|
|
18
15
|
if (!observable) {
|
|
19
|
-
observable =
|
|
16
|
+
observable = fromEvent(emitter, event).pipe(share());
|
|
20
17
|
emitterEvents.set(event, observable);
|
|
21
18
|
}
|
|
22
19
|
return observable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Command } from './command';
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
import Rx from 'rxjs';
|
|
3
|
+
import { Command } from './command.js';
|
|
4
4
|
/**
|
|
5
5
|
* Class responsible for actually writing output onto a writable stream.
|
|
6
6
|
*/
|
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.OutputWriter = void 0;
|
|
37
|
-
const Rx = __importStar(require("rxjs"));
|
|
38
|
-
const observables_1 = require("./observables");
|
|
1
|
+
import Rx from 'rxjs';
|
|
2
|
+
import { fromSharedEvent } from './observables.js';
|
|
39
3
|
/**
|
|
40
4
|
* Class responsible for actually writing output onto a writable stream.
|
|
41
5
|
*/
|
|
42
|
-
class OutputWriter {
|
|
6
|
+
export class OutputWriter {
|
|
43
7
|
outputStream;
|
|
44
8
|
group;
|
|
45
9
|
buffers;
|
|
@@ -51,7 +15,7 @@ class OutputWriter {
|
|
|
51
15
|
constructor({ outputStream, group, commands, }) {
|
|
52
16
|
this.outputStream = outputStream;
|
|
53
17
|
this.ensureWritable();
|
|
54
|
-
this.error =
|
|
18
|
+
this.error = fromSharedEvent(this.outputStream, 'error');
|
|
55
19
|
this.group = group;
|
|
56
20
|
this.buffers = commands.map(() => []);
|
|
57
21
|
if (this.group) {
|
|
@@ -97,4 +61,3 @@ class OutputWriter {
|
|
|
97
61
|
this.buffers[index] = [];
|
|
98
62
|
}
|
|
99
63
|
}
|
|
100
|
-
exports.OutputWriter = OutputWriter;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChalkInstance } from 'chalk';
|
|
2
|
+
export declare class PrefixColorSelector {
|
|
3
|
+
private colorGenerator;
|
|
4
|
+
constructor(customColors?: string | string[]);
|
|
5
|
+
/**
|
|
6
|
+
* Colors used by `auto` selection and default cycling.
|
|
7
|
+
*
|
|
8
|
+
* Each color is chosen to be visually distinct on both dark and light
|
|
9
|
+
* terminal backgrounds, without carrying semantic meaning (e.g. red
|
|
10
|
+
* implies errors) or blending into default text (e.g. white/grey).
|
|
11
|
+
* Background colors are excluded to keep output lightweight.
|
|
12
|
+
*
|
|
13
|
+
* This list does NOT restrict manually specified colors — any valid Chalk
|
|
14
|
+
* color name, hex value, or modifier can be passed via `--prefix-colors`.
|
|
15
|
+
*/
|
|
16
|
+
static get ACCEPTABLE_CONSOLE_COLORS(): (keyof ChalkInstance)[];
|
|
17
|
+
/**
|
|
18
|
+
* @returns The given custom colors then a set of acceptable console colors indefinitely.
|
|
19
|
+
*/
|
|
20
|
+
getNextColor(): string;
|
|
21
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PrefixColorSelector = void 0;
|
|
4
1
|
function getConsoleColorsWithoutCustomColors(customColors) {
|
|
5
2
|
return PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS.filter(
|
|
6
3
|
// Consider the "Bright" variants of colors to be the same as the plain color to avoid similar colors
|
|
@@ -51,44 +48,30 @@ function* createColorGenerator(customColors) {
|
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
class PrefixColorSelector {
|
|
51
|
+
export class PrefixColorSelector {
|
|
55
52
|
colorGenerator;
|
|
56
53
|
constructor(customColors = []) {
|
|
57
54
|
const normalizedColors = typeof customColors === 'string' ? [customColors] : customColors;
|
|
58
55
|
this.colorGenerator = createColorGenerator(normalizedColors);
|
|
59
56
|
}
|
|
60
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Colors used by `auto` selection and default cycling.
|
|
59
|
+
*
|
|
60
|
+
* Each color is chosen to be visually distinct on both dark and light
|
|
61
|
+
* terminal backgrounds, without carrying semantic meaning (e.g. red
|
|
62
|
+
* implies errors) or blending into default text (e.g. white/grey).
|
|
63
|
+
* Background colors are excluded to keep output lightweight.
|
|
64
|
+
*
|
|
65
|
+
* This list does NOT restrict manually specified colors — any valid Chalk
|
|
66
|
+
* color name, hex value, or modifier can be passed via `--prefix-colors`.
|
|
67
|
+
*/
|
|
61
68
|
static get ACCEPTABLE_CONSOLE_COLORS() {
|
|
62
|
-
|
|
63
|
-
return [
|
|
64
|
-
// Prevent duplicates, in case the list becomes significantly large
|
|
65
|
-
...new Set([
|
|
66
|
-
// Text colors
|
|
67
|
-
'cyan',
|
|
68
|
-
'yellow',
|
|
69
|
-
'greenBright',
|
|
70
|
-
'blueBright',
|
|
71
|
-
'magentaBright',
|
|
72
|
-
'white',
|
|
73
|
-
'grey',
|
|
74
|
-
'red',
|
|
75
|
-
// Background colors
|
|
76
|
-
'bgCyan',
|
|
77
|
-
'bgYellow',
|
|
78
|
-
'bgGreenBright',
|
|
79
|
-
'bgBlueBright',
|
|
80
|
-
'bgMagenta',
|
|
81
|
-
'bgWhiteBright',
|
|
82
|
-
'bgGrey',
|
|
83
|
-
'bgRed',
|
|
84
|
-
]),
|
|
85
|
-
];
|
|
69
|
+
return [...new Set(['cyan', 'magenta', 'green', 'yellow', 'blue'])];
|
|
86
70
|
}
|
|
87
71
|
/**
|
|
88
72
|
* @returns The given custom colors then a set of acceptable console colors indefinitely.
|
|
89
73
|
*/
|
|
90
74
|
getNextColor() {
|
|
91
|
-
return this.colorGenerator.next().value;
|
|
75
|
+
return this.colorGenerator.next().value.trim();
|
|
92
76
|
}
|
|
93
77
|
}
|
|
94
|
-
exports.PrefixColorSelector = PrefixColorSelector;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { ChildProcess, SpawnOptions } from 'child_process';
|
|
2
|
-
import
|
|
1
|
+
import { ChildProcess, SpawnOptions } from 'node:child_process';
|
|
2
|
+
import { ColorSupport } from 'supports-color';
|
|
3
|
+
import { SpawnCommand } from './command.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Creates a spawn function that uses the given shell executable.
|
|
6
|
+
*
|
|
7
|
+
* The shell is resolved in the following priority order:
|
|
8
|
+
* 1. explicit shell option
|
|
9
|
+
* 2. `npm_config_script_shell` env variable
|
|
10
|
+
* 3. platform default (`cmd.exe` on Windows, `/bin/sh` elsewhere)
|
|
11
|
+
*
|
|
12
|
+
* @see https://docs.npmjs.com/cli/v6/using-npm/config#script-shell
|
|
5
13
|
*/
|
|
6
|
-
export declare function
|
|
14
|
+
export declare function createSpawn(shell?: string, spawn?: (command: string, args: string[], options: SpawnOptions) => ChildProcess, process?: Pick<NodeJS.Process, 'platform' | 'env'>): SpawnCommand;
|
|
15
|
+
export type ShellKind = 'cmd' | 'posix' | 'powershell';
|
|
7
16
|
export declare const getSpawnOpts: ({ colorSupport, cwd, process, ipc, stdio, env, }: {
|
|
8
17
|
/**
|
|
9
18
|
* What the color support of the spawned processes should be.
|
|
@@ -11,7 +20,7 @@ export declare const getSpawnOpts: ({ colorSupport, cwd, process, ipc, stdio, en
|
|
|
11
20
|
*
|
|
12
21
|
* Defaults to whatever the terminal's stdout support is.
|
|
13
22
|
*/
|
|
14
|
-
colorSupport?: Pick<
|
|
23
|
+
colorSupport?: Pick<ColorSupport, "level"> | false;
|
|
15
24
|
/**
|
|
16
25
|
* The NodeJS process.
|
|
17
26
|
*/
|