@emend-ai/utim 1.43.0 → 1.43.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/bin/utim.js +8 -6
- package/package.json +1 -1
- package/scripts/postinstall.js +3 -2
package/bin/utim.js
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
const { spawnSync, spawn } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
5
6
|
const fs = require('fs');
|
|
6
7
|
|
|
7
8
|
const args = process.argv.slice(2);
|
|
9
|
+
const useShell = os.platform() === 'win32';
|
|
8
10
|
|
|
9
11
|
// ── Find a working Python 3 interpreter ──────────────────────────────────────
|
|
10
12
|
function findPython() {
|
|
11
13
|
for (const candidate of ['python3', 'python']) {
|
|
12
14
|
try {
|
|
13
|
-
const r = spawnSync(candidate, ['--version'], { encoding: 'utf8', timeout: 3000, shell:
|
|
15
|
+
const r = spawnSync(candidate, ['--version'], { encoding: 'utf8', timeout: 3000, shell: useShell });
|
|
14
16
|
const out = (r.stdout || '') + (r.stderr || '');
|
|
15
17
|
if (out.includes('Python 3')) return candidate;
|
|
16
18
|
} catch (_) {}
|
|
@@ -21,11 +23,11 @@ function findPython() {
|
|
|
21
23
|
// ── Attempt to launch a command, return true if successful ───────────────────
|
|
22
24
|
function tryLaunch(cmd, launchArgs) {
|
|
23
25
|
try {
|
|
24
|
-
const probe = spawnSync(cmd, ['--version'], { shell:
|
|
26
|
+
const probe = spawnSync(cmd, ['--version'], { shell: useShell, timeout: 3000, encoding: 'utf8' });
|
|
25
27
|
const out = (probe.stdout || '') + (probe.stderr || '');
|
|
26
28
|
// accept if exit 0 OR if it printed something (some tools exit non-0 for --version)
|
|
27
29
|
if (probe.status === 0 || out.length > 0) {
|
|
28
|
-
const proc = spawn(cmd, launchArgs, { stdio: 'inherit', shell:
|
|
30
|
+
const proc = spawn(cmd, launchArgs, { stdio: 'inherit', shell: useShell });
|
|
29
31
|
proc.on('exit', (code) => process.exit(code == null ? 0 : code));
|
|
30
32
|
return true;
|
|
31
33
|
}
|
|
@@ -41,9 +43,9 @@ function tryEntryPoint() {
|
|
|
41
43
|
// ── Try via `python -m utim_cli.utim` ───────────────────────────────────────
|
|
42
44
|
function tryModule(python) {
|
|
43
45
|
try {
|
|
44
|
-
const probe = spawnSync(python, ['-m', 'utim_cli', '--help'], { shell:
|
|
46
|
+
const probe = spawnSync(python, ['-m', 'utim_cli', '--help'], { shell: useShell, timeout: 5000 });
|
|
45
47
|
if (probe.status === 0) {
|
|
46
|
-
const proc = spawn(python, ['-m', 'utim_cli.utim', ...args], { stdio: 'inherit', shell:
|
|
48
|
+
const proc = spawn(python, ['-m', 'utim_cli.utim', ...args], { stdio: 'inherit', shell: useShell });
|
|
47
49
|
proc.on('exit', (code) => process.exit(code == null ? 0 : code));
|
|
48
50
|
return true;
|
|
49
51
|
}
|
|
@@ -56,7 +58,7 @@ function selfInstallAndRun(python) {
|
|
|
56
58
|
console.error('\n⚙ First run: installing UTIM Python engine from PyPI...');
|
|
57
59
|
const install = spawnSync(python, ['-m', 'pip', 'install', '--upgrade', 'utim-cli'], {
|
|
58
60
|
stdio: 'inherit',
|
|
59
|
-
shell:
|
|
61
|
+
shell: useShell,
|
|
60
62
|
});
|
|
61
63
|
if (install.status === 0) {
|
|
62
64
|
// Retry the entry point after install
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -14,6 +14,7 @@ const path = require('path');
|
|
|
14
14
|
const os = require('os');
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
|
|
17
|
+
const useShell = os.platform() === 'win32';
|
|
17
18
|
const pkgDir = path.resolve(__dirname, '..');
|
|
18
19
|
|
|
19
20
|
// ── Find a usable Python 3 interpreter ────────────────────────────────────────
|
|
@@ -23,7 +24,7 @@ function findPython() {
|
|
|
23
24
|
const r = spawnSync(candidate, ['--version'], {
|
|
24
25
|
encoding: 'utf8',
|
|
25
26
|
timeout: 4000,
|
|
26
|
-
shell:
|
|
27
|
+
shell: useShell,
|
|
27
28
|
});
|
|
28
29
|
const out = (r.stdout || '') + (r.stderr || '');
|
|
29
30
|
if (out.includes('Python 3')) return candidate;
|
|
@@ -39,7 +40,7 @@ function installFromPyPI(python) {
|
|
|
39
40
|
const r = spawnSync(
|
|
40
41
|
python,
|
|
41
42
|
['-m', 'pip', 'install', '--upgrade', 'utim-cli'],
|
|
42
|
-
{ stdio: 'inherit', shell:
|
|
43
|
+
{ stdio: 'inherit', shell: useShell }
|
|
43
44
|
);
|
|
44
45
|
return r.status === 0;
|
|
45
46
|
} catch (_) {
|