@suryasairus/core 1.0.2 → 1.0.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/bin/cli.js +18 -9
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
4
|
const { spawn } = require('child_process');
|
|
3
5
|
const path = require('path');
|
|
4
6
|
|
|
5
7
|
const arg = process.argv[2] || 'dev';
|
|
6
8
|
const corePath = path.resolve(__dirname, '..');
|
|
7
9
|
const userPath = process.cwd();
|
|
8
|
-
const isWindows = process.platform === 'win32';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
// --- NEW HOISTING-SAFE LOGIC START ---
|
|
12
|
+
let nextBin;
|
|
13
|
+
try {
|
|
14
|
+
// Finds the actual location of the 'next' package
|
|
15
|
+
const nextPkgPath = require.resolve('next/package.json', { paths: [corePath, userPath] });
|
|
16
|
+
nextBin = path.resolve(path.dirname(nextPkgPath), '../.bin/next');
|
|
17
|
+
} catch (e) {
|
|
18
|
+
// Fallback if the package isn't found via require
|
|
19
|
+
nextBin = path.resolve(corePath, 'node_modules', '.bin', 'next');
|
|
20
|
+
}
|
|
21
|
+
// --- NEW HOISTING-SAFE LOGIC END ---
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
// but we pass 'corePath' as the argument so Next knows where the code is.
|
|
14
|
-
const child = spawn(`"${nextBin}"`, [arg, `"${corePath}"` ], {
|
|
23
|
+
const child = spawn(nextBin, [arg, corePath], {
|
|
15
24
|
stdio: 'inherit',
|
|
16
|
-
shell: true,
|
|
17
|
-
cwd: userPath,
|
|
25
|
+
shell: true,
|
|
26
|
+
cwd: userPath,
|
|
18
27
|
env: {
|
|
19
28
|
...process.env,
|
|
20
29
|
NEXT_PUBLIC_USER_CWD: userPath
|
|
21
30
|
}
|
|
22
31
|
});
|
|
23
32
|
|
|
24
|
-
child.on('exit', (code) => process.exit(code));
|
|
33
|
+
child.on('exit', (code) => process.exit(code || 0));
|