@codemoreira/esad 1.4.6-31 → 1.4.6-33
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/cli/commands/host.js +4 -4
- package/src/cli/utils/process.js +30 -6
package/package.json
CHANGED
package/src/cli/commands/host.js
CHANGED
|
@@ -123,10 +123,10 @@ module.exports = async (subcommand) => {
|
|
|
123
123
|
// 6. Launch Native App
|
|
124
124
|
if (choice === 'a') {
|
|
125
125
|
console.log(`🤖 Compiling and launching on Android...`);
|
|
126
|
-
await runProcess('
|
|
126
|
+
await runProcess('react-native', ['run-android', '--no-packager'], cwd);
|
|
127
127
|
} else if (choice === 'i') {
|
|
128
128
|
console.log(`🍎 Compiling and launching on iOS...`);
|
|
129
|
-
await runProcess('
|
|
129
|
+
await runProcess('react-native', ['run-ios', '--no-packager'], cwd);
|
|
130
130
|
} else if (choice === 'b') {
|
|
131
131
|
if (portBusy) {
|
|
132
132
|
console.log(`✨ Bundler is already active. You can launch manual native runs.`);
|
|
@@ -140,9 +140,9 @@ module.exports = async (subcommand) => {
|
|
|
140
140
|
// Other subcommands (android, ios directly)
|
|
141
141
|
try {
|
|
142
142
|
if (subcommand === 'android') {
|
|
143
|
-
await runProcess('
|
|
143
|
+
await runProcess('react-native', ['run-android', '--no-packager'], cwd);
|
|
144
144
|
} else if (subcommand === 'ios') {
|
|
145
|
-
await runProcess('
|
|
145
|
+
await runProcess('react-native', ['run-ios', '--no-packager'], cwd);
|
|
146
146
|
}
|
|
147
147
|
} catch (err) {
|
|
148
148
|
console.error(`❌ Error running host command: ${err.message}`);
|
package/src/cli/utils/process.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const { spawn } = require('cross-spawn');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs-extra');
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Helper to spawn commands synchronously
|
|
@@ -9,18 +11,40 @@ const { spawn } = require('cross-spawn');
|
|
|
9
11
|
*/
|
|
10
12
|
const runProcess = (cmd, args, cwd = process.cwd()) => {
|
|
11
13
|
return new Promise((resolve, reject) => {
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
+
let finished = false;
|
|
15
|
+
const finalize = (fn, arg) => {
|
|
16
|
+
if (finished) return;
|
|
17
|
+
finished = true;
|
|
18
|
+
fn(arg);
|
|
19
|
+
};
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
// Try to find a local binary in node_modules/.bin first
|
|
22
|
+
const isWin = process.platform === 'win32';
|
|
23
|
+
const localBinPath = path.join(cwd, 'node_modules', '.bin', isWin ? `${cmd}.cmd` : cmd);
|
|
24
|
+
|
|
25
|
+
let command = cmd;
|
|
26
|
+
let finalArgs = args;
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(localBinPath)) {
|
|
29
|
+
command = localBinPath;
|
|
30
|
+
} else {
|
|
31
|
+
// Fallback to npx
|
|
32
|
+
command = isWin ? 'npx.cmd' : 'npx';
|
|
33
|
+
finalArgs = [cmd, ...args];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const child = spawn(command, finalArgs, { stdio: 'inherit', cwd, shell: true });
|
|
16
37
|
|
|
17
38
|
child.on('error', err => {
|
|
18
|
-
reject
|
|
39
|
+
finalize(reject, new Error(`Failed to spawn command ${command}: ${err.message}`));
|
|
19
40
|
});
|
|
20
41
|
|
|
21
42
|
child.on('close', code => {
|
|
22
|
-
if (code !== 0)
|
|
23
|
-
|
|
43
|
+
if (code !== 0) {
|
|
44
|
+
finalize(reject, new Error(`Command ${command} ${finalArgs.join(' ')} failed with exit code ${code}`));
|
|
45
|
+
} else {
|
|
46
|
+
finalize(resolve);
|
|
47
|
+
}
|
|
24
48
|
});
|
|
25
49
|
});
|
|
26
50
|
};
|