command-stream 0.8.1 → 0.8.2
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 +1 -1
- package/src/$.mjs +61 -10
- package/src/commands/$.cp.mjs +1 -1
- package/src/commands/$.env.mjs +1 -1
- package/src/commands/$.ls.mjs +1 -1
- package/src/commands/$.mkdir.mjs +1 -1
- package/src/commands/$.mv.mjs +2 -2
- package/src/commands/$.pwd.mjs +1 -1
- package/src/commands/$.rm.mjs +1 -1
- package/src/commands/$.touch.mjs +1 -1
- package/src/commands/$.yes.mjs +1 -1
package/package.json
CHANGED
package/src/$.mjs
CHANGED
|
@@ -42,7 +42,40 @@ function findAvailableShell() {
|
|
|
42
42
|
return cachedShell;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const isWindows = process.platform === 'win32';
|
|
46
|
+
|
|
47
|
+
// Windows-specific shells
|
|
48
|
+
const windowsShells = [
|
|
49
|
+
// Git Bash is the most Unix-compatible option on Windows
|
|
50
|
+
// Check common installation paths
|
|
51
|
+
{
|
|
52
|
+
cmd: 'C:\\Program Files\\Git\\bin\\bash.exe',
|
|
53
|
+
args: ['-c'],
|
|
54
|
+
checkPath: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
cmd: 'C:\\Program Files\\Git\\usr\\bin\\bash.exe',
|
|
58
|
+
args: ['-c'],
|
|
59
|
+
checkPath: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
cmd: 'C:\\Program Files (x86)\\Git\\bin\\bash.exe',
|
|
63
|
+
args: ['-c'],
|
|
64
|
+
checkPath: true,
|
|
65
|
+
},
|
|
66
|
+
// Git Bash via PATH (if added to PATH by user)
|
|
67
|
+
{ cmd: 'bash.exe', args: ['-c'], checkPath: false },
|
|
68
|
+
// WSL bash as fallback
|
|
69
|
+
{ cmd: 'wsl.exe', args: ['bash', '-c'], checkPath: false },
|
|
70
|
+
// PowerShell as last resort (different syntax for commands)
|
|
71
|
+
{ cmd: 'powershell.exe', args: ['-Command'], checkPath: false },
|
|
72
|
+
{ cmd: 'pwsh.exe', args: ['-Command'], checkPath: false },
|
|
73
|
+
// cmd.exe as final fallback
|
|
74
|
+
{ cmd: 'cmd.exe', args: ['/c'], checkPath: false },
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
// Unix-specific shells
|
|
78
|
+
const unixShells = [
|
|
46
79
|
// Try absolute paths first (most reliable)
|
|
47
80
|
{ cmd: '/bin/sh', args: ['-l', '-c'], checkPath: true },
|
|
48
81
|
{ cmd: '/usr/bin/sh', args: ['-l', '-c'], checkPath: true },
|
|
@@ -71,6 +104,9 @@ function findAvailableShell() {
|
|
|
71
104
|
{ cmd: 'zsh', args: ['-l', '-c'], checkPath: false },
|
|
72
105
|
];
|
|
73
106
|
|
|
107
|
+
// Select shells based on platform
|
|
108
|
+
const shellsToTry = isWindows ? windowsShells : unixShells;
|
|
109
|
+
|
|
74
110
|
for (const shell of shellsToTry) {
|
|
75
111
|
try {
|
|
76
112
|
if (shell.checkPath) {
|
|
@@ -84,12 +120,15 @@ function findAvailableShell() {
|
|
|
84
120
|
return cachedShell;
|
|
85
121
|
}
|
|
86
122
|
} else {
|
|
87
|
-
//
|
|
88
|
-
const
|
|
123
|
+
// On Windows, use 'where' instead of 'which'
|
|
124
|
+
const whichCmd = isWindows ? 'where' : 'which';
|
|
125
|
+
const result = cp.spawnSync(whichCmd, [shell.cmd], {
|
|
89
126
|
encoding: 'utf-8',
|
|
127
|
+
// On Windows, we need shell: true for 'where' to work
|
|
128
|
+
shell: isWindows,
|
|
90
129
|
});
|
|
91
130
|
if (result.status === 0 && result.stdout) {
|
|
92
|
-
const shellPath = result.stdout.trim();
|
|
131
|
+
const shellPath = result.stdout.trim().split('\n')[0]; // Take first result
|
|
93
132
|
trace(
|
|
94
133
|
'ShellDetection',
|
|
95
134
|
() => `Found shell in PATH: ${shell.cmd} => ${shellPath}`
|
|
@@ -100,15 +139,27 @@ function findAvailableShell() {
|
|
|
100
139
|
}
|
|
101
140
|
} catch (e) {
|
|
102
141
|
// Continue to next shell option
|
|
142
|
+
trace(
|
|
143
|
+
'ShellDetection',
|
|
144
|
+
() => `Failed to check shell ${shell.cmd}: ${e.message}`
|
|
145
|
+
);
|
|
103
146
|
}
|
|
104
147
|
}
|
|
105
148
|
|
|
106
|
-
// Final fallback
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
149
|
+
// Final fallback based on platform
|
|
150
|
+
if (isWindows) {
|
|
151
|
+
trace(
|
|
152
|
+
'ShellDetection',
|
|
153
|
+
() => 'WARNING: No shell found, using cmd.exe as fallback on Windows'
|
|
154
|
+
);
|
|
155
|
+
cachedShell = { cmd: 'cmd.exe', args: ['/c'] };
|
|
156
|
+
} else {
|
|
157
|
+
trace(
|
|
158
|
+
'ShellDetection',
|
|
159
|
+
() => 'WARNING: No shell found, using /bin/sh as fallback'
|
|
160
|
+
);
|
|
161
|
+
cachedShell = { cmd: '/bin/sh', args: ['-l', '-c'] };
|
|
162
|
+
}
|
|
112
163
|
return cachedShell;
|
|
113
164
|
}
|
|
114
165
|
|
package/src/commands/$.cp.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { trace, VirtualUtils } from '../$.utils.mjs';
|
|
4
4
|
|
|
5
|
-
export default async function cp({ args, stdin, cwd }) {
|
|
5
|
+
export default async function cp({ args, stdin: _stdin, cwd }) {
|
|
6
6
|
const argError = VirtualUtils.validateArgs(args, 2, 'cp');
|
|
7
7
|
if (argError) {
|
|
8
8
|
return VirtualUtils.invalidArgumentError(
|
package/src/commands/$.env.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VirtualUtils } from '../$.utils.mjs';
|
|
2
2
|
|
|
3
|
-
export default async function env({ args, stdin, env }) {
|
|
3
|
+
export default async function env({ args, stdin: _stdin, env }) {
|
|
4
4
|
if (args.length === 0) {
|
|
5
5
|
// Use custom env if provided, otherwise use process.env
|
|
6
6
|
const envVars = env || process.env;
|
package/src/commands/$.ls.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { trace, VirtualUtils } from '../$.utils.mjs';
|
|
4
4
|
|
|
5
|
-
export default async function ls({ args, stdin, cwd }) {
|
|
5
|
+
export default async function ls({ args, stdin: _stdin, cwd }) {
|
|
6
6
|
try {
|
|
7
7
|
// Parse flags
|
|
8
8
|
const flags = new Set();
|
package/src/commands/$.mkdir.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { trace, VirtualUtils } from '../$.utils.mjs';
|
|
3
3
|
|
|
4
|
-
export default async function mkdir({ args, stdin, cwd }) {
|
|
4
|
+
export default async function mkdir({ args, stdin: _stdin, cwd }) {
|
|
5
5
|
const argError = VirtualUtils.validateArgs(args, 1, 'mkdir');
|
|
6
6
|
if (argError) {
|
|
7
7
|
return argError;
|
package/src/commands/$.mv.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { trace, VirtualUtils } from '../$.utils.mjs';
|
|
4
4
|
|
|
5
|
-
export default async function mv({ args, stdin, cwd }) {
|
|
5
|
+
export default async function mv({ args, stdin: _stdin, cwd }) {
|
|
6
6
|
const argError = VirtualUtils.validateArgs(args, 2, 'mv');
|
|
7
7
|
if (argError) {
|
|
8
8
|
return VirtualUtils.invalidArgumentError(
|
|
@@ -62,7 +62,7 @@ export default async function mv({ args, stdin, cwd }) {
|
|
|
62
62
|
const sourcePath = VirtualUtils.resolvePath(source, cwd);
|
|
63
63
|
|
|
64
64
|
try {
|
|
65
|
-
const
|
|
65
|
+
const _sourceStats = fs.statSync(sourcePath);
|
|
66
66
|
let finalDestPath = destPath;
|
|
67
67
|
|
|
68
68
|
if (destIsDir) {
|
package/src/commands/$.pwd.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { trace, VirtualUtils } from '../$.utils.mjs';
|
|
2
2
|
|
|
3
|
-
export default async function pwd({ args, stdin, cwd }) {
|
|
3
|
+
export default async function pwd({ args: _args, stdin: _stdin, cwd }) {
|
|
4
4
|
// If cwd option is provided, return that instead of process.cwd()
|
|
5
5
|
const dir = cwd || process.cwd();
|
|
6
6
|
trace(
|
package/src/commands/$.rm.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { trace, VirtualUtils } from '../$.utils.mjs';
|
|
3
3
|
|
|
4
|
-
export default async function rm({ args, stdin, cwd }) {
|
|
4
|
+
export default async function rm({ args, stdin: _stdin, cwd }) {
|
|
5
5
|
const argError = VirtualUtils.validateArgs(args, 1, 'rm');
|
|
6
6
|
if (argError) {
|
|
7
7
|
return argError;
|
package/src/commands/$.touch.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { trace, VirtualUtils } from '../$.utils.mjs';
|
|
3
3
|
|
|
4
|
-
export default async function touch({ args, stdin, cwd }) {
|
|
4
|
+
export default async function touch({ args, stdin: _stdin, cwd }) {
|
|
5
5
|
const argError = VirtualUtils.validateArgs(args, 1, 'touch');
|
|
6
6
|
if (argError) {
|
|
7
7
|
return VirtualUtils.missingOperandError(
|