@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemoreira/esad",
3
- "version": "1.4.6-31",
3
+ "version": "1.4.6-33",
4
4
  "description": "Easy Super App Development - Zero-Config CLI and DevTools for React Native Module Federation",
5
5
  "main": "src/plugin/index.js",
6
6
  "types": "./src/plugin/index.d.ts",
@@ -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('npx', ['react-native', 'run-android', '--no-packager'], cwd);
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('npx', ['react-native', 'run-ios', '--no-packager'], cwd);
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('npx', ['react-native', 'run-android', '--no-packager'], cwd);
143
+ await runProcess('react-native', ['run-android', '--no-packager'], cwd);
144
144
  } else if (subcommand === 'ios') {
145
- await runProcess('npx', ['react-native', 'run-ios', '--no-packager'], cwd);
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}`);
@@ -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
- // On Windows, npx must be executed as npx.cmd
13
- const command = process.platform === 'win32' && cmd === 'npx' ? 'npx.cmd' : cmd;
14
+ let finished = false;
15
+ const finalize = (fn, arg) => {
16
+ if (finished) return;
17
+ finished = true;
18
+ fn(arg);
19
+ };
14
20
 
15
- const child = spawn(command, args, { stdio: 'inherit', cwd, shell: true });
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(new Error(`Failed to spawn command ${command}: ${err.message}`));
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) reject(new Error(`Command ${command} ${args.join(' ')} failed with exit code ${code}`));
23
- else resolve();
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
  };