@entelligentsia/forgecli 0.9.2 → 0.9.3
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/CHANGELOG.md +12 -0
- package/dist/CHANGELOG-pi.md +14 -19
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +6 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +80 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +20 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +14 -19
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +35 -27
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/template.js +17 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +4 -8
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +3 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +5 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +14 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +13 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/dark.json +5 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/light.json +5 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +21 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +82 -40
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +22 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts +5 -8
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js +8 -59
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.js +6 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.js.map +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/windows-self-update.d.ts +3 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/windows-self-update.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/windows-self-update.js +77 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/windows-self-update.js.map +1 -0
- package/node_modules/@earendil-works/pi-coding-agent/docs/index.md +8 -0
- package/node_modules/@earendil-works/pi-coding-agent/docs/packages.md +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/docs/quickstart.md +20 -0
- package/node_modules/@earendil-works/pi-coding-agent/docs/usage.md +2 -0
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/README.md +3 -0
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/index.ts +41 -19
- package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -4
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +3 -4
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/node_modules/cross-spawn/LICENSE +21 -0
- package/node_modules/cross-spawn/README.md +89 -0
- package/node_modules/cross-spawn/index.js +39 -0
- package/node_modules/cross-spawn/lib/enoent.js +59 -0
- package/node_modules/cross-spawn/lib/parse.js +91 -0
- package/node_modules/cross-spawn/lib/util/escape.js +47 -0
- package/node_modules/cross-spawn/lib/util/readShebang.js +23 -0
- package/node_modules/cross-spawn/lib/util/resolveCommand.js +52 -0
- package/node_modules/cross-spawn/package.json +73 -0
- package/node_modules/isexe/.npmignore +2 -0
- package/node_modules/isexe/LICENSE +15 -0
- package/node_modules/isexe/README.md +51 -0
- package/node_modules/isexe/index.js +57 -0
- package/node_modules/isexe/mode.js +41 -0
- package/node_modules/isexe/package.json +31 -0
- package/node_modules/isexe/test/basic.js +221 -0
- package/node_modules/isexe/windows.js +42 -0
- package/node_modules/path-key/index.d.ts +40 -0
- package/node_modules/path-key/index.js +16 -0
- package/node_modules/path-key/license +9 -0
- package/node_modules/path-key/package.json +39 -0
- package/node_modules/path-key/readme.md +61 -0
- package/node_modules/shebang-command/index.js +19 -0
- package/node_modules/shebang-command/license +9 -0
- package/node_modules/shebang-command/package.json +34 -0
- package/node_modules/shebang-command/readme.md +34 -0
- package/node_modules/shebang-regex/index.d.ts +22 -0
- package/node_modules/shebang-regex/index.js +2 -0
- package/node_modules/shebang-regex/license +9 -0
- package/node_modules/shebang-regex/package.json +35 -0
- package/node_modules/shebang-regex/readme.md +33 -0
- package/node_modules/which/LICENSE +15 -0
- package/node_modules/which/README.md +54 -0
- package/node_modules/which/bin/node-which +52 -0
- package/node_modules/which/package.json +43 -0
- package/node_modules/which/which.js +125 -0
- package/package.json +6 -6
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const cp = require('child_process');
|
|
4
|
+
const parse = require('./lib/parse');
|
|
5
|
+
const enoent = require('./lib/enoent');
|
|
6
|
+
|
|
7
|
+
function spawn(command, args, options) {
|
|
8
|
+
// Parse the arguments
|
|
9
|
+
const parsed = parse(command, args, options);
|
|
10
|
+
|
|
11
|
+
// Spawn the child process
|
|
12
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
13
|
+
|
|
14
|
+
// Hook into child process "exit" event to emit an error if the command
|
|
15
|
+
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
16
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
17
|
+
|
|
18
|
+
return spawned;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function spawnSync(command, args, options) {
|
|
22
|
+
// Parse the arguments
|
|
23
|
+
const parsed = parse(command, args, options);
|
|
24
|
+
|
|
25
|
+
// Spawn the child process
|
|
26
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
27
|
+
|
|
28
|
+
// Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
29
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = spawn;
|
|
35
|
+
module.exports.spawn = spawn;
|
|
36
|
+
module.exports.sync = spawnSync;
|
|
37
|
+
|
|
38
|
+
module.exports._parse = parse;
|
|
39
|
+
module.exports._enoent = enoent;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const isWin = process.platform === 'win32';
|
|
4
|
+
|
|
5
|
+
function notFoundError(original, syscall) {
|
|
6
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
7
|
+
code: 'ENOENT',
|
|
8
|
+
errno: 'ENOENT',
|
|
9
|
+
syscall: `${syscall} ${original.command}`,
|
|
10
|
+
path: original.command,
|
|
11
|
+
spawnargs: original.args,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function hookChildProcess(cp, parsed) {
|
|
16
|
+
if (!isWin) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const originalEmit = cp.emit;
|
|
21
|
+
|
|
22
|
+
cp.emit = function (name, arg1) {
|
|
23
|
+
// If emitting "exit" event and exit code is 1, we need to check if
|
|
24
|
+
// the command exists and emit an "error" instead
|
|
25
|
+
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
26
|
+
if (name === 'exit') {
|
|
27
|
+
const err = verifyENOENT(arg1, parsed);
|
|
28
|
+
|
|
29
|
+
if (err) {
|
|
30
|
+
return originalEmit.call(cp, 'error', err);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function verifyENOENT(status, parsed) {
|
|
39
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
40
|
+
return notFoundError(parsed.original, 'spawn');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function verifyENOENTSync(status, parsed) {
|
|
47
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
48
|
+
return notFoundError(parsed.original, 'spawnSync');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
hookChildProcess,
|
|
56
|
+
verifyENOENT,
|
|
57
|
+
verifyENOENTSync,
|
|
58
|
+
notFoundError,
|
|
59
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const resolveCommand = require('./util/resolveCommand');
|
|
5
|
+
const escape = require('./util/escape');
|
|
6
|
+
const readShebang = require('./util/readShebang');
|
|
7
|
+
|
|
8
|
+
const isWin = process.platform === 'win32';
|
|
9
|
+
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
10
|
+
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
11
|
+
|
|
12
|
+
function detectShebang(parsed) {
|
|
13
|
+
parsed.file = resolveCommand(parsed);
|
|
14
|
+
|
|
15
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
16
|
+
|
|
17
|
+
if (shebang) {
|
|
18
|
+
parsed.args.unshift(parsed.file);
|
|
19
|
+
parsed.command = shebang;
|
|
20
|
+
|
|
21
|
+
return resolveCommand(parsed);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return parsed.file;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function parseNonShell(parsed) {
|
|
28
|
+
if (!isWin) {
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Detect & add support for shebangs
|
|
33
|
+
const commandFile = detectShebang(parsed);
|
|
34
|
+
|
|
35
|
+
// We don't need a shell if the command filename is an executable
|
|
36
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
37
|
+
|
|
38
|
+
// If a shell is required, use cmd.exe and take care of escaping everything correctly
|
|
39
|
+
// Note that `forceShell` is an hidden option used only in tests
|
|
40
|
+
if (parsed.options.forceShell || needsShell) {
|
|
41
|
+
// Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
|
|
42
|
+
// The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
|
|
43
|
+
// Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
|
|
44
|
+
// we need to double escape them
|
|
45
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
46
|
+
|
|
47
|
+
// Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
|
|
48
|
+
// This is necessary otherwise it will always fail with ENOENT in those cases
|
|
49
|
+
parsed.command = path.normalize(parsed.command);
|
|
50
|
+
|
|
51
|
+
// Escape command & arguments
|
|
52
|
+
parsed.command = escape.command(parsed.command);
|
|
53
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
54
|
+
|
|
55
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(' ');
|
|
56
|
+
|
|
57
|
+
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
|
|
58
|
+
parsed.command = process.env.comspec || 'cmd.exe';
|
|
59
|
+
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return parsed;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function parse(command, args, options) {
|
|
66
|
+
// Normalize arguments, similar to nodejs
|
|
67
|
+
if (args && !Array.isArray(args)) {
|
|
68
|
+
options = args;
|
|
69
|
+
args = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
args = args ? args.slice(0) : []; // Clone array to avoid changing the original
|
|
73
|
+
options = Object.assign({}, options); // Clone object to avoid changing the original
|
|
74
|
+
|
|
75
|
+
// Build our parsed object
|
|
76
|
+
const parsed = {
|
|
77
|
+
command,
|
|
78
|
+
args,
|
|
79
|
+
options,
|
|
80
|
+
file: undefined,
|
|
81
|
+
original: {
|
|
82
|
+
command,
|
|
83
|
+
args,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Delegate further parsing to shell or non-shell
|
|
88
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = parse;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// See http://www.robvanderwoude.com/escapechars.php
|
|
4
|
+
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
5
|
+
|
|
6
|
+
function escapeCommand(arg) {
|
|
7
|
+
// Escape meta chars
|
|
8
|
+
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
9
|
+
|
|
10
|
+
return arg;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
14
|
+
// Convert to string
|
|
15
|
+
arg = `${arg}`;
|
|
16
|
+
|
|
17
|
+
// Algorithm below is based on https://qntm.org/cmd
|
|
18
|
+
// It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
|
|
19
|
+
// Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
|
|
20
|
+
|
|
21
|
+
// Sequence of backslashes followed by a double quote:
|
|
22
|
+
// double up all the backslashes and escape the double quote
|
|
23
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
24
|
+
|
|
25
|
+
// Sequence of backslashes followed by the end of the string
|
|
26
|
+
// (which will become a double quote later):
|
|
27
|
+
// double up all the backslashes
|
|
28
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, '$1$1');
|
|
29
|
+
|
|
30
|
+
// All other backslashes occur literally
|
|
31
|
+
|
|
32
|
+
// Quote the whole thing:
|
|
33
|
+
arg = `"${arg}"`;
|
|
34
|
+
|
|
35
|
+
// Escape meta chars
|
|
36
|
+
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
37
|
+
|
|
38
|
+
// Double escape meta chars if necessary
|
|
39
|
+
if (doubleEscapeMetaChars) {
|
|
40
|
+
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return arg;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports.command = escapeCommand;
|
|
47
|
+
module.exports.argument = escapeArgument;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const shebangCommand = require('shebang-command');
|
|
5
|
+
|
|
6
|
+
function readShebang(command) {
|
|
7
|
+
// Read the first 150 bytes from the file
|
|
8
|
+
const size = 150;
|
|
9
|
+
const buffer = Buffer.alloc(size);
|
|
10
|
+
|
|
11
|
+
let fd;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
fd = fs.openSync(command, 'r');
|
|
15
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
16
|
+
fs.closeSync(fd);
|
|
17
|
+
} catch (e) { /* Empty */ }
|
|
18
|
+
|
|
19
|
+
// Attempt to extract shebang (null is returned if not a shebang)
|
|
20
|
+
return shebangCommand(buffer.toString());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = readShebang;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const which = require('which');
|
|
5
|
+
const getPathKey = require('path-key');
|
|
6
|
+
|
|
7
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
8
|
+
const env = parsed.options.env || process.env;
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
11
|
+
// Worker threads do not have process.chdir()
|
|
12
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
|
|
13
|
+
|
|
14
|
+
// If a custom `cwd` was specified, we need to change the process cwd
|
|
15
|
+
// because `which` will do stat calls but does not support a custom cwd
|
|
16
|
+
if (shouldSwitchCwd) {
|
|
17
|
+
try {
|
|
18
|
+
process.chdir(parsed.options.cwd);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
/* Empty */
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let resolved;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
resolved = which.sync(parsed.command, {
|
|
28
|
+
path: env[getPathKey({ env })],
|
|
29
|
+
pathExt: withoutPathExt ? path.delimiter : undefined,
|
|
30
|
+
});
|
|
31
|
+
} catch (e) {
|
|
32
|
+
/* Empty */
|
|
33
|
+
} finally {
|
|
34
|
+
if (shouldSwitchCwd) {
|
|
35
|
+
process.chdir(cwd);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// If we successfully resolved, ensure that an absolute path is returned
|
|
40
|
+
// Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
|
|
41
|
+
if (resolved) {
|
|
42
|
+
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return resolved;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function resolveCommand(parsed) {
|
|
49
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = resolveCommand;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cross-spawn",
|
|
3
|
+
"version": "7.0.6",
|
|
4
|
+
"description": "Cross platform child_process#spawn and child_process#spawnSync",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"spawn",
|
|
7
|
+
"spawnSync",
|
|
8
|
+
"windows",
|
|
9
|
+
"cross-platform",
|
|
10
|
+
"path-ext",
|
|
11
|
+
"shebang",
|
|
12
|
+
"cmd",
|
|
13
|
+
"execute"
|
|
14
|
+
],
|
|
15
|
+
"author": "André Cruz <andre@moxy.studio>",
|
|
16
|
+
"homepage": "https://github.com/moxystudio/node-cross-spawn",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git@github.com:moxystudio/node-cross-spawn.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"main": "index.js",
|
|
23
|
+
"files": [
|
|
24
|
+
"lib"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"lint": "eslint .",
|
|
28
|
+
"test": "jest --env node --coverage",
|
|
29
|
+
"prerelease": "npm t && npm run lint",
|
|
30
|
+
"release": "standard-version",
|
|
31
|
+
"postrelease": "git push --follow-tags origin HEAD && npm publish"
|
|
32
|
+
},
|
|
33
|
+
"husky": {
|
|
34
|
+
"hooks": {
|
|
35
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
36
|
+
"pre-commit": "lint-staged"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"lint-staged": {
|
|
40
|
+
"*.js": [
|
|
41
|
+
"eslint --fix",
|
|
42
|
+
"git add"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"commitlint": {
|
|
46
|
+
"extends": [
|
|
47
|
+
"@commitlint/config-conventional"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"path-key": "^3.1.0",
|
|
52
|
+
"shebang-command": "^2.0.0",
|
|
53
|
+
"which": "^2.0.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@commitlint/cli": "^8.1.0",
|
|
57
|
+
"@commitlint/config-conventional": "^8.1.0",
|
|
58
|
+
"babel-core": "^6.26.3",
|
|
59
|
+
"babel-jest": "^24.9.0",
|
|
60
|
+
"babel-preset-moxy": "^3.1.0",
|
|
61
|
+
"eslint": "^5.16.0",
|
|
62
|
+
"eslint-config-moxy": "^7.1.0",
|
|
63
|
+
"husky": "^3.0.5",
|
|
64
|
+
"jest": "^24.9.0",
|
|
65
|
+
"lint-staged": "^9.2.5",
|
|
66
|
+
"mkdirp": "^0.5.1",
|
|
67
|
+
"rimraf": "^3.0.0",
|
|
68
|
+
"standard-version": "^9.5.0"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">= 8"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
The ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# isexe
|
|
2
|
+
|
|
3
|
+
Minimal module to check if a file is executable, and a normal file.
|
|
4
|
+
|
|
5
|
+
Uses `fs.stat` and tests against the `PATHEXT` environment variable on
|
|
6
|
+
Windows.
|
|
7
|
+
|
|
8
|
+
## USAGE
|
|
9
|
+
|
|
10
|
+
```javascript
|
|
11
|
+
var isexe = require('isexe')
|
|
12
|
+
isexe('some-file-name', function (err, isExe) {
|
|
13
|
+
if (err) {
|
|
14
|
+
console.error('probably file does not exist or something', err)
|
|
15
|
+
} else if (isExe) {
|
|
16
|
+
console.error('this thing can be run')
|
|
17
|
+
} else {
|
|
18
|
+
console.error('cannot be run')
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// same thing but synchronous, throws errors
|
|
23
|
+
var isExe = isexe.sync('some-file-name')
|
|
24
|
+
|
|
25
|
+
// treat errors as just "not executable"
|
|
26
|
+
isexe('maybe-missing-file', { ignoreErrors: true }, callback)
|
|
27
|
+
var isExe = isexe.sync('maybe-missing-file', { ignoreErrors: true })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API
|
|
31
|
+
|
|
32
|
+
### `isexe(path, [options], [callback])`
|
|
33
|
+
|
|
34
|
+
Check if the path is executable. If no callback provided, and a
|
|
35
|
+
global `Promise` object is available, then a Promise will be returned.
|
|
36
|
+
|
|
37
|
+
Will raise whatever errors may be raised by `fs.stat`, unless
|
|
38
|
+
`options.ignoreErrors` is set to true.
|
|
39
|
+
|
|
40
|
+
### `isexe.sync(path, [options])`
|
|
41
|
+
|
|
42
|
+
Same as `isexe` but returns the value and throws any errors raised.
|
|
43
|
+
|
|
44
|
+
### Options
|
|
45
|
+
|
|
46
|
+
* `ignoreErrors` Treat all errors as "no, this is not executable", but
|
|
47
|
+
don't raise them.
|
|
48
|
+
* `uid` Number to use as the user id
|
|
49
|
+
* `gid` Number to use as the group id
|
|
50
|
+
* `pathExt` List of path extensions to use instead of `PATHEXT`
|
|
51
|
+
environment variable on Windows.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var fs = require('fs')
|
|
2
|
+
var core
|
|
3
|
+
if (process.platform === 'win32' || global.TESTING_WINDOWS) {
|
|
4
|
+
core = require('./windows.js')
|
|
5
|
+
} else {
|
|
6
|
+
core = require('./mode.js')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = isexe
|
|
10
|
+
isexe.sync = sync
|
|
11
|
+
|
|
12
|
+
function isexe (path, options, cb) {
|
|
13
|
+
if (typeof options === 'function') {
|
|
14
|
+
cb = options
|
|
15
|
+
options = {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!cb) {
|
|
19
|
+
if (typeof Promise !== 'function') {
|
|
20
|
+
throw new TypeError('callback not provided')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return new Promise(function (resolve, reject) {
|
|
24
|
+
isexe(path, options || {}, function (er, is) {
|
|
25
|
+
if (er) {
|
|
26
|
+
reject(er)
|
|
27
|
+
} else {
|
|
28
|
+
resolve(is)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
core(path, options || {}, function (er, is) {
|
|
35
|
+
// ignore EACCES because that just means we aren't allowed to run it
|
|
36
|
+
if (er) {
|
|
37
|
+
if (er.code === 'EACCES' || options && options.ignoreErrors) {
|
|
38
|
+
er = null
|
|
39
|
+
is = false
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
cb(er, is)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function sync (path, options) {
|
|
47
|
+
// my kingdom for a filtered catch
|
|
48
|
+
try {
|
|
49
|
+
return core.sync(path, options || {})
|
|
50
|
+
} catch (er) {
|
|
51
|
+
if (options && options.ignoreErrors || er.code === 'EACCES') {
|
|
52
|
+
return false
|
|
53
|
+
} else {
|
|
54
|
+
throw er
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module.exports = isexe
|
|
2
|
+
isexe.sync = sync
|
|
3
|
+
|
|
4
|
+
var fs = require('fs')
|
|
5
|
+
|
|
6
|
+
function isexe (path, options, cb) {
|
|
7
|
+
fs.stat(path, function (er, stat) {
|
|
8
|
+
cb(er, er ? false : checkStat(stat, options))
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function sync (path, options) {
|
|
13
|
+
return checkStat(fs.statSync(path), options)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function checkStat (stat, options) {
|
|
17
|
+
return stat.isFile() && checkMode(stat, options)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function checkMode (stat, options) {
|
|
21
|
+
var mod = stat.mode
|
|
22
|
+
var uid = stat.uid
|
|
23
|
+
var gid = stat.gid
|
|
24
|
+
|
|
25
|
+
var myUid = options.uid !== undefined ?
|
|
26
|
+
options.uid : process.getuid && process.getuid()
|
|
27
|
+
var myGid = options.gid !== undefined ?
|
|
28
|
+
options.gid : process.getgid && process.getgid()
|
|
29
|
+
|
|
30
|
+
var u = parseInt('100', 8)
|
|
31
|
+
var g = parseInt('010', 8)
|
|
32
|
+
var o = parseInt('001', 8)
|
|
33
|
+
var ug = u | g
|
|
34
|
+
|
|
35
|
+
var ret = (mod & o) ||
|
|
36
|
+
(mod & g) && gid === myGid ||
|
|
37
|
+
(mod & u) && uid === myUid ||
|
|
38
|
+
(mod & ug) && myUid === 0
|
|
39
|
+
|
|
40
|
+
return ret
|
|
41
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "isexe",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Minimal module to check if a file is executable.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"directories": {
|
|
7
|
+
"test": "test"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"mkdirp": "^0.5.1",
|
|
11
|
+
"rimraf": "^2.5.0",
|
|
12
|
+
"tap": "^10.3.0"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "tap test/*.js --100",
|
|
16
|
+
"preversion": "npm test",
|
|
17
|
+
"postversion": "npm publish",
|
|
18
|
+
"postpublish": "git push origin --all; git push origin --tags"
|
|
19
|
+
},
|
|
20
|
+
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/isaacs/isexe.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [],
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/isaacs/isexe/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/isaacs/isexe#readme"
|
|
31
|
+
}
|