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

fix(docz-core): forward cli status code properly #1319

Merged
merged 1 commit into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/docz-core/src/bundler/build.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as fs from 'fs-extra'
import * as path from 'path'
import spawn from 'cross-spawn'
import sh from 'shelljs'

import * as paths from '../config/paths'
import { BuildFn } from '../lib/Bundler'
import { ensureFiles } from './machine/actions'
import { spawnSync } from '../utils/spawn'

export const build: BuildFn = async (config, dist) => {
const publicDir = path.join(paths.docz, 'public')
Expand All @@ -19,6 +19,6 @@ export const build: BuildFn = async (config, dist) => {
}
ensureFiles({ args: config })
sh.cd(paths.docz)
spawn.sync('npm', cliArgs, { stdio: 'inherit' })
spawnSync('npm', cliArgs)
await fs.copy(publicDir, dist)
}
4 changes: 2 additions & 2 deletions core/docz-core/src/commands/serve.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import spawn from 'cross-spawn'
import sh from 'shelljs'

import * as paths from '../config/paths'
import { spawnSync } from '../utils/spawn'

export const serve = async () => {
const cliArgs = ['run', 'serve']
sh.cd(paths.docz)
spawn.sync('npm', cliArgs, { stdio: 'inherit' })
spawnSync('npm', cliArgs)
}
13 changes: 13 additions & 0 deletions core/docz-core/src/utils/spawn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import crossSpawn from 'cross-spawn'

export const spawnSync = (command: string, args?: readonly string[]) => {
const output = crossSpawn.sync(command, args, {
stdio: ['inherit', 'inherit', 'pipe'],
})

if (!output.stderr) {
return
}

process.exitCode = output.status || 1
}