@code-pushup/utils 0.65.0 → 0.65.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/utils",
|
|
3
|
-
"version": "0.65.
|
|
3
|
+
"version": "0.65.1",
|
|
4
4
|
"description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/utils#readme",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"node": ">=17.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@code-pushup/models": "0.65.
|
|
30
|
+
"@code-pushup/models": "0.65.1",
|
|
31
31
|
"@isaacs/cliui": "^8.0.2",
|
|
32
32
|
"@poppinss/cliui": "^6.4.0",
|
|
33
33
|
"ansis": "^3.3.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { gray } from 'ansis';
|
|
2
1
|
import { spawn, } from 'node:child_process';
|
|
3
|
-
import {
|
|
2
|
+
import { formatCommandLog } from './format-command-log.js';
|
|
3
|
+
import { isVerbose, ui } from './logging.js';
|
|
4
4
|
import { calcDuration } from './reports/utils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Error class for process errors.
|
|
@@ -64,8 +64,9 @@ export function executeProcess(cfg) {
|
|
|
64
64
|
const { onStdout, onStderr, onError, onComplete } = observer ?? {};
|
|
65
65
|
const date = new Date().toISOString();
|
|
66
66
|
const start = performance.now();
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
if (isVerbose()) {
|
|
68
|
+
ui().logger.log(formatCommandLog(command, args, `${cfg.cwd ?? process.cwd()}`));
|
|
69
|
+
}
|
|
69
70
|
return new Promise((resolve, reject) => {
|
|
70
71
|
// shell:true tells Windows to use shell command for spawning a child process
|
|
71
72
|
const spawnedProcess = spawn(command, args ?? [], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-process.js","sourceRoot":"","sources":["../../../../../packages/utils/src/lib/execute-process.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"execute-process.js","sourceRoot":"","sources":["../../../../../packages/utils/src/lib/execute-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GACN,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAkBlD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,IAAI,CAAgB;IACpB,MAAM,CAAS;IACf,MAAM,CAAS;IAEf,YAAY,MAAqB;QAC/B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;CACF;AA6DD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,cAAc,CAAC,GAAkB;IAC/C,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,CAAC;IAC5E,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,QAAQ,IAAI,EAAE,CAAC;IACnE,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,WAAW,C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AG,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACxD,IAAI,IAAI,KAAK,CAAC,IAAI,cAAc,EAAE,CAAC;gBACjC,UAAU,EAAE,EAAE,CAAC;gBACf,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;YAChD,CAAC;iBAAM,CAAC;gBACN,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;gBACxE,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;gBACpB,MAAM,CAAC,QAAQ,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a command string with optional cwd prefix and ANSI colors.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} command - The command to execute.
|
|
5
|
+
* @param {string[]} args - Array of command arguments.
|
|
6
|
+
* @param {string} [cwd] - Optional current working directory for the command.
|
|
7
|
+
* @returns {string} - ANSI-colored formatted command string.
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatCommandLog(command: string, args?: string[], cwd?: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import ansis from 'ansis';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Formats a command string with optional cwd prefix and ANSI colors.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} command - The command to execute.
|
|
7
|
+
* @param {string[]} args - Array of command arguments.
|
|
8
|
+
* @param {string} [cwd] - Optional current working directory for the command.
|
|
9
|
+
* @returns {string} - ANSI-colored formatted command string.
|
|
10
|
+
*/
|
|
11
|
+
export function formatCommandLog(command, args = [], cwd = process.cwd()) {
|
|
12
|
+
const relativeDir = path.relative(process.cwd(), cwd);
|
|
13
|
+
return [
|
|
14
|
+
...(relativeDir && relativeDir !== '.'
|
|
15
|
+
? [ansis.italic(ansis.gray(relativeDir))]
|
|
16
|
+
: []),
|
|
17
|
+
ansis.yellow('$'),
|
|
18
|
+
ansis.gray(command),
|
|
19
|
+
ansis.gray(args.map(arg => arg).join(' ')),
|
|
20
|
+
].join(' ');
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=format-command-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-command-log.js","sourceRoot":"","sources":["../../../../../packages/utils/src/lib/format-command-log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,OAAiB,EAAE,EACnB,MAAc,OAAO,CAAC,GAAG,EAAE;IAE3B,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;IAEtD,OAAO;QACL,GAAG,CAAC,WAAW,IAAI,WAAW,KAAK,GAAG;YACpC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC,EAAE,CAAC;QACP,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC3C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC"}
|