Ver Fonte

meta: fix build of TypeScript plugins (#4784)

Antoine du Hamel há 1 ano atrás
pai
commit
70ffe60947
1 ficheiros alterados com 17 adições e 20 exclusões
  1. 17 20
      bin/build-ts.mjs

+ 17 - 20
bin/build-ts.mjs

@@ -14,28 +14,25 @@ const argv0 = fromYarn ? [] : ['yarn']
 
 const cwd = fileURLToPath(new URL('../', import.meta.url))
 
+const locations = []
+
 for await (const line of readLines(stdin)) {
-  const { location, name } = JSON.parse(line)
+  const { location } = JSON.parse(line)
   if (existsSync(path.join(cwd, location, 'tsconfig.json'))) {
-    const cp = spawn(exe, [...argv0, 'tsc', '-p', location], {
-      stdio: 'inherit',
-      cwd,
-    })
-    await Promise.race([
-      once(cp, 'error').then(err => Promise.reject(err)),
-      await once(cp, 'exit')
-        .then(([code]) => (code && Promise.reject(new Error(`Non-zero exit code when building "${name}": ${code}`)))),
-    ])
+    locations.unshift(location)
   }
-  if (existsSync(path.join(cwd, location, 'tsconfig.build.json'))) {
-    const cp = spawn(exe, [...argv0, 'tsc', '--build', path.join(cwd, location, 'tsconfig.build.json')], {
-      stdio: 'inherit',
-      cwd,
-    })
-    await Promise.race([
-      once(cp, 'error').then(err => Promise.reject(err)),
-      await once(cp, 'exit')
-        .then(([code]) => (code && Promise.reject(new Error(`Non-zero exit code when building "${name}": ${code}`)))),
-    ])
+  const tsConfigBuildPath = path.join(cwd, location, 'tsconfig.build.json')
+  if (existsSync(tsConfigBuildPath)) {
+    locations.push(tsConfigBuildPath)
   }
 }
+
+const cp = spawn(exe, [...argv0, 'tsc', '--build', ...locations], {
+  stdio: 'inherit',
+  cwd,
+})
+await Promise.race([
+  once(cp, 'error').then(err => Promise.reject(err)),
+  await once(cp, 'exit')
+    .then(([code]) => (code && Promise.reject(new Error(`Non-zero exit code when building TS projects: ${code}`)))),
+])