Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 99ebf82

Browse files
adbaybrakannimer
authored andcommitted
fix(docz-core): forward cli status code properly (#1319)
1 parent 29e0165 commit 99ebf82

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

core/docz-core/src/bundler/build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as fs from 'fs-extra'
22
import * as path from 'path'
3-
import spawn from 'cross-spawn'
43
import sh from 'shelljs'
54

65
import * as paths from '../config/paths'
76
import { BuildFn } from '../lib/Bundler'
87
import { ensureFiles } from './machine/actions'
8+
import { spawnSync } from '../utils/spawn'
99

1010
export const build: BuildFn = async (config, dist) => {
1111
const publicDir = path.join(paths.docz, 'public')
@@ -19,6 +19,6 @@ export const build: BuildFn = async (config, dist) => {
1919
}
2020
ensureFiles({ args: config })
2121
sh.cd(paths.docz)
22-
spawn.sync('npm', cliArgs, { stdio: 'inherit' })
22+
spawnSync('npm', cliArgs)
2323
await fs.copy(publicDir, dist)
2424
}

core/docz-core/src/commands/serve.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import spawn from 'cross-spawn'
21
import sh from 'shelljs'
32

43
import * as paths from '../config/paths'
4+
import { spawnSync } from '../utils/spawn'
55

66
export const serve = async () => {
77
const cliArgs = ['run', 'serve']
88
sh.cd(paths.docz)
9-
spawn.sync('npm', cliArgs, { stdio: 'inherit' })
9+
spawnSync('npm', cliArgs)
1010
}

core/docz-core/src/utils/spawn.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import crossSpawn from 'cross-spawn'
2+
3+
export const spawnSync = (command: string, args?: readonly string[]) => {
4+
const output = crossSpawn.sync(command, args, {
5+
stdio: ['inherit', 'inherit', 'pipe'],
6+
})
7+
8+
if (!output.stderr) {
9+
return
10+
}
11+
12+
process.exitCode = output.status || 1
13+
}

0 commit comments

Comments
 (0)