Browse Source

fix(subprocess): close native platform CI gaps

pku-xht 1 tháng trước cách đây
mục cha
commit
1fc04feb77

+ 1 - 1
packages/subprocess/subprocess-local/src/linux-scope.ts

@@ -41,7 +41,7 @@ function querySystemctl(command: string, args: readonly string[]): Promise<Syste
     execFile(command, [...args], { encoding: 'utf8', timeout: SYSTEMCTL_TIMEOUT_MS }, (error, stdout, stderr) => {
       const code = error === null ? 0 : (error as Error & { code?: string | number }).code
       resolve({
-        status: typeof code === 'number' ? code : error === null ? 0 : null,
+        status: typeof code === 'number' ? code : null,
         stdout,
         stderr,
         ...error === null ? {} : { error },

+ 7 - 3
packages/subprocess/subprocess-local/tests/native-windows.spec.ts

@@ -57,9 +57,13 @@ function cleanup(pid: number): void {
 
 function directSpawnFailure(argv: string[]): Promise<NodeJS.ErrnoException> {
   return new Promise((resolve, reject) => {
-    const child = spawn(argv[0] as string, argv.slice(1), { cwd: scratch, stdio: 'ignore' })
-    child.once('error', resolve)
-    child.once('spawn', () => { reject(new Error(`expected ${argv[0]} to fail before spawn`)) })
+    try {
+      const child = spawn(argv[0] as string, argv.slice(1), { cwd: scratch, stdio: 'ignore' })
+      child.once('error', resolve)
+      child.once('spawn', () => { reject(new Error(`expected ${argv[0]} to fail before spawn`)) })
+    } catch (error) {
+      resolve(error as NodeJS.ErrnoException)
+    }
   })
 }