@codemoreira/esad 1.4.6-34 → 1.4.6-35

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-34",
3
+ "version": "1.4.6-35",
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",
@@ -1,17 +1,13 @@
1
1
  const { spawn } = require('cross-spawn');
2
+ const nativeSpawn = require('child_process').spawn;
2
3
  const path = require('path');
3
4
  const fs = require('fs-extra');
4
5
 
5
- /**
6
- * Helper to spawn commands synchronously
7
- * @param {string} cmd
8
- * @param {string[]} args
9
- * @param {string} cwd
10
- * @returns {Promise<void>}
11
- */
12
6
  const runProcess = (cmd, args, cwd = process.cwd()) => {
13
7
  return new Promise((resolve, reject) => {
14
8
  let finished = false;
9
+ let started = false;
10
+
15
11
  const finalize = (fn, arg) => {
16
12
  if (finished) return;
17
13
  finished = true;
@@ -23,24 +19,36 @@ const runProcess = (cmd, args, cwd = process.cwd()) => {
23
19
 
24
20
  let command = cmd;
25
21
  let finalArgs = args;
22
+ let useNativeSpawn = false;
26
23
 
27
24
  if (fs.existsSync(localBinPath)) {
28
- // Use RELATIVE path for Windows stability
29
25
  command = isWin ? `node_modules\\.bin\\${cmd}.cmd` : `./node_modules/.bin/${cmd}`;
26
+ useNativeSpawn = isWin; // Use native spawn on Windows for local binaries to avoid cross-spawn issues
30
27
  } else {
31
- command = isWin ? `${cmd}.cmd` : cmd;
28
+ command = isWin ? 'npx.cmd' : 'npx';
29
+ finalArgs = [cmd, ...args];
32
30
  }
33
31
 
34
32
  console.log(`[ESAD] Resolved Command: ${command} (CWD: ${cwd})`);
35
33
 
36
- const child = spawn(command, finalArgs, {
34
+ // Mark as started after a short delay
35
+ setTimeout(() => { started = true; }, 2000);
36
+
37
+ const spawnFn = useNativeSpawn ? nativeSpawn : spawn;
38
+ const child = spawnFn(command, finalArgs, {
37
39
  stdio: 'inherit',
38
40
  cwd,
39
41
  shell: true
40
42
  });
41
43
 
42
44
  child.on('error', err => {
43
- // Log more details to understand when this happens
45
+ // If the process already "started" (ran for > 2s), we ignore early-spawn errors
46
+ // as they are likely shell artifacts from the process exiting.
47
+ if (started && err.code === 'ENOENT') {
48
+ console.warn(`[ESAD] Warning: Late ENOENT ignored for ${cmd}.`);
49
+ return;
50
+ }
51
+
44
52
  console.error(`[ESAD] Process Error: ${err.code} - ${err.message}`);
45
53
  finalize(reject, new Error(`Failed to start ${cmd}: ${err.message}`));
46
54
  });