Skip to content

Commit

Permalink
fix: 打包出错时 为了保证工具链完整 需要 出错code为1
Browse files Browse the repository at this point in the history
  • Loading branch information
imsunhao committed Mar 18, 2019
1 parent 3505775 commit 775dbfc
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ function getArgv() {

if (argv.hostname === '') {
consola.fatal('Provided hostname argument has no value')
process.exit(0)
process.exit(1)
}

if (argv.output === '') {
consola.fatal('Provided output argument has no value')
process.exit(0)
process.exit(1)
}

if (argv.entry === '') {
consola.fatal('Provided entry argument has no value')
process.exit(0)
process.exit(1)
}

string.forEach(index => {
Expand All @@ -86,7 +86,7 @@ function getArgv() {
const configFile = resolve(rootDir, argv['config-file'])
if (!fs.existsSync(configFile)) {
consola.fatal('configFile is not exists', configFile)
return process.exit(0)
return process.exit(1)
}

let options = {}
Expand All @@ -96,7 +96,7 @@ function getArgv() {
options = JSON.parse(jsonString)
} catch (error) {
consola.fatal('clear:', error)
return process.exit(0)
return process.exit(1)
}

path = resolve(rootDir, options.output || './dist/build')
Expand Down
2 changes: 1 addition & 1 deletion src/config/webpack.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getBaseConfig(options: ConfigOptions.options) {
consola.fatal(
'getBaseConfig options.babelrc or options.webpack is undefined'
)
return process.exit(0)
return process.exit(1)
}
const mode = options.webpack.mode || 'production'
const isProd = mode === 'production'
Expand Down
2 changes: 1 addition & 1 deletion src/config/webpack.dll.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getDllConfig(
): webpack.Configuration {
if (!(options.webpack && options.webpack.dll)) {
consola.fatal('getDllConfig options.webpack.dll is undefined')
return process.exit(0)
return process.exit(1)
}

const mode = options.webpack.mode || 'production'
Expand Down
2 changes: 1 addition & 1 deletion src/config/webpack.extensions.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function getExtensionsConfig(
consola.fatal(
'getExtensionsConfig options.extensions.entry or options.babelrc is undefined'
)
return process.exit(0)
return process.exit(1)
}

const babelLoder = {
Expand Down
4 changes: 2 additions & 2 deletions src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function serverExtensions(this: any, app?: Express, opt?: BuildServ
if (opt && opt.noCompiler) {
if (!app) {
consola.fatal('serverExtensions', 'app is undefined')
return process.exit(0)
return process.exit(1)
}
const outputPath = config.extensions.path
const entrys = config.extensions.entry
Expand All @@ -31,7 +31,7 @@ export async function serverExtensions(this: any, app?: Express, opt?: BuildServ
extensions = requireFromString(souce).default
} catch (error) {
consola.fatal('serverExtensions', error)
return process.exit(0)
return process.exit(1)
}
Object.keys(extensions).forEach(extensionKey => {
const extension = extensions[extensionKey]
Expand Down
4 changes: 2 additions & 2 deletions src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function clientManifestAddDll(clientManifest: any) {
})
} catch (error) {
consola.fatal('clientManifestAddDll', error)
return process.exit(0)
return process.exit(1)
}
}
return clientManifest
Expand Down Expand Up @@ -212,6 +212,6 @@ export function serverRender(app: Express) {
}
} catch (error) {
consola.fatal('config.render', error)
process.exit(0)
process.exit(1)
}
}
20 changes: 10 additions & 10 deletions src/utils/compiler.webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function devCompiler({
consola.fatal(
'{clientConfig, serverConfig}.{output, plugins, entry} is undefined'
)
return process.exit(0)
return process.exit(1)
}

const entry: any = clientConfig.entry
Expand Down Expand Up @@ -165,7 +165,7 @@ export function compilerConfig(

if (!(entry && output)) {
consola.fatal('compilerConfig: entry or output is undefined')
return process.exit(0)
return process.exit(1)
}

webpackConfig.mode = mode
Expand All @@ -189,7 +189,7 @@ export function compilerConfig(
config = requireFromString(souce)
} catch (error) {
consola.fatal('compilerConfig', error)
return process.exit(0)
return process.exit(1)
} finally {
done(config)
}
Expand All @@ -205,7 +205,7 @@ export function compilerConfig(
config = requireFromString(souce)
} catch (error) {
consola.fatal('compilerConfig', error)
return process.exit(0)
return process.exit(1)
} finally {
done(config)
}
Expand All @@ -215,7 +215,7 @@ export function compilerConfig(
})
} else {
consola.fatal('compilerConfig: config path not find.', path)
return process.exit(0)
return process.exit(1)
}
})
}
Expand All @@ -235,7 +235,7 @@ export function compilerDll(options: ConfigOptions.options): Promise<any> {
stats.warnings.forEach((err: any) => consola.info(err))
if (stats.errors.length) {
consola.fatal('build dll fail!')
return process.exit(0)
return process.exit(1)
}
done()
})
Expand Down Expand Up @@ -265,7 +265,7 @@ export async function compilerExtensions(
) {
if (!(options.webpack && options.extensions && options.webpack.mode)) {
consola.fatal('options.extensions or options.webpack.mode is undefined')
return process.exit(0)
return process.exit(1)
}

const isProd = options.webpack.mode === 'production'
Expand All @@ -289,7 +289,7 @@ function prodCompilerExtensions(options: ConfigOptions.options) {
stats.warnings.forEach((err: any) => consola.info(err))
if (stats.errors.length) {
consola.fatal('build extensions fail!')
return process.exit(0)
return process.exit(1)
}
done()
})
Expand All @@ -310,7 +310,7 @@ function prodCompilerExtensions(options: ConfigOptions.options) {
function devCompilerExtensions(options: ConfigOptions.options, app?: Express) {
if (!(app && options.extensions && options.extensions.entry)) {
consola.fatal('devCompilerExtensions: app is undefined')
return process.exit(0)
return process.exit(1)
}

const outputPath = options.extensions.path
Expand Down Expand Up @@ -346,7 +346,7 @@ function devCompilerExtensions(options: ConfigOptions.options, app?: Express) {
extensions = requireFromString(souce).default
} catch (error) {
consola.fatal('devCompilerExtensions', error)
return process.exit(0)
return process.exit(1)
}
Object.keys(extensions).forEach(extensionKey => {
const extension = extensions[extensionKey]
Expand Down
14 changes: 7 additions & 7 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function getConfigFileOptions(
const configFile = resolve(rootDir, argv['config-file'])
if (!existsSync(configFile)) {
consola.fatal('entry is not exists', configFile)
return process.exit(0)
return process.exit(1)
}

let options: any = {}
Expand All @@ -46,7 +46,7 @@ function getConfigFileOptions(
options = JSON.parse(jsonString)
} catch (error) {
consola.fatal(error)
return process.exit(0)
return process.exit(1)
}

const { entry, output, injectContext } = options
Expand Down Expand Up @@ -129,7 +129,7 @@ function setVersion(options: ConfigOptions.options) {
return options
} catch (error) {
consola.fatal('setVersion', error)
return process.exit(0)
return process.exit(1)
}
}

Expand Down Expand Up @@ -187,7 +187,7 @@ function getInjectContext(configOptions: BuildService.parsedArgs.config) {
Object.assign(injectContext, JSON.parse(jsonString))
} catch (error) {
consola.fatal(error)
return process.exit(0)
return process.exit(1)
}
}
return injectContext
Expand Down Expand Up @@ -228,7 +228,7 @@ async function getUserConfig(
}
} else if (argv['config-file'] !== 'buildService.config.js') {
consola.fatal('Could not load config file: ' + argv['config-file'])
return process.exit(0)
return process.exit(1)
}

if (!options.injectContext) {
Expand Down Expand Up @@ -299,7 +299,7 @@ async function checkDll(
if (argv.dll) {
if (!(options.webpack && options.webpack.dll)) {
consola.fatal('options.webpack.dll is undefined')
return process.exit(0)
return process.exit(1)
}

await compilerDll(options)
Expand Down Expand Up @@ -376,7 +376,7 @@ export function serverStart(
start()
}, WAIT_TIME)
} else {
process.exit(0)
process.exit(1)
}
})
server.on('listening', function() {
Expand Down

0 comments on commit 775dbfc

Please sign in to comment.