node-power-user 2.3.0 → 2.3.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/dist/commands/install.js +1 -1
- package/dist/commands/npm.js +1 -1
- package/dist/lib/npx-args.js +17 -5
- package/dist/lib/socket.js +4 -1
- package/package.json +2 -1
package/dist/commands/install.js
CHANGED
|
@@ -43,7 +43,7 @@ module.exports = async function (options) {
|
|
|
43
43
|
npm.removeInstalledCopies(names);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const command = `npm install ${
|
|
46
|
+
const command = `npm install ${npxArgs.quoteArgs(childArgs)}`.trim();
|
|
47
47
|
|
|
48
48
|
// Check socket status upfront (blocks if not installed unless --force)
|
|
49
49
|
await socket.check({ force });
|
package/dist/commands/npm.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = async function (options) {
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const command = `npm ${
|
|
27
|
+
const command = `npm ${npxArgs.quoteArgs(childArgs)}`;
|
|
28
28
|
|
|
29
29
|
// Check firewall status upfront (blocks if not installed unless --force)
|
|
30
30
|
await socket.check({ force });
|
package/dist/lib/npx-args.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Tokens that select the npx command (positional + flag alias)
|
|
7
7
|
const NPX_TOKENS = ['npx', '--npx'];
|
|
8
8
|
|
|
9
|
-
// Args matching this need no quoting for POSIX sh (commands run with shell: true)
|
|
9
|
+
// Args matching this need no quoting for POSIX sh or cmd.exe (commands run with shell: true)
|
|
10
10
|
const SAFE_ARG = /^[A-Za-z0-9_\-./@=:,+]+$/;
|
|
11
11
|
|
|
12
12
|
// Split raw argv into npu's own flags (before the command token) and the
|
|
@@ -47,18 +47,29 @@ function firstPositional(args) {
|
|
|
47
47
|
return (args || []).find((arg) => !arg.startsWith('-')) || null;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
//
|
|
51
|
-
|
|
50
|
+
// Quote an arg for the shell when it contains anything unsafe: single quotes
|
|
51
|
+
// for POSIX sh; double quotes for cmd.exe, which keeps single quotes as text,
|
|
52
|
+
// escaped the way the C runtime splits argv (backslashes before a quote double)
|
|
53
|
+
function quoteArg(arg, platform = process.platform) {
|
|
52
54
|
if (SAFE_ARG.test(arg)) {
|
|
53
55
|
return arg;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
if (platform === 'win32') {
|
|
59
|
+
return `"${String(arg).replace(/(\\*)"/g, '$1$1\\"').replace(/(\\+)$/, '$1$1')}"`;
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
return `'${String(arg).replace(/'/g, `'\\''`)}'`;
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
// Quote each arg and join them, the one way every command string is built
|
|
66
|
+
function quoteArgs(args, platform = process.platform) {
|
|
67
|
+
return args.map((arg) => quoteArg(arg, platform)).join(' ');
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
// Rebuild the npx command string with shell-safe quoting
|
|
60
|
-
function buildCommand(childArgs) {
|
|
61
|
-
return
|
|
71
|
+
function buildCommand(childArgs, platform = process.platform) {
|
|
72
|
+
return `npx ${quoteArgs(childArgs, platform)}`.trim();
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
// Export
|
|
@@ -68,5 +79,6 @@ module.exports = {
|
|
|
68
79
|
forcesDownload,
|
|
69
80
|
firstPositional,
|
|
70
81
|
quoteArg,
|
|
82
|
+
quoteArgs,
|
|
71
83
|
buildCommand,
|
|
72
84
|
};
|
package/dist/lib/socket.js
CHANGED
|
@@ -69,7 +69,10 @@ async function wrap(command, options) {
|
|
|
69
69
|
let output = '';
|
|
70
70
|
let exitCode = null;
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
// The child shares npu's stdin: a pipe npu never closes leaves `sfw npm
|
|
73
|
+
// install` waiting forever on Windows, and an install that prompts can read
|
|
74
|
+
// the terminal. Only stdout/stderr are piped, for the live echo below.
|
|
75
|
+
const executeOptions = { log: !wrapped, config: wrapped ? { stdio: ['inherit', 'pipe', 'pipe'] } : {} };
|
|
73
76
|
|
|
74
77
|
// The wrapped child runs on pipes (not a TTY), which disables color in most
|
|
75
78
|
// CLIs — restore it, but only when npu itself is printing to a real TTY
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-power-user",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Easy tools for every Node.js developer!",
|
|
5
|
+
"private": false,
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "npm run prepare && mocha test/ --recursive --timeout=10000",
|