Comparing version 0.1.24 to 0.1.25
@@ -16,2 +16,3 @@ export declare type Target = 'esnext' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020'; | ||
format?: Format; | ||
color?: boolean; | ||
external?: string[]; | ||
@@ -30,2 +31,7 @@ | ||
entryPoints: string[]; | ||
// This defaults to "pipe" which exposes a property called "stderr" on the | ||
// result. This can be set to "inherit" instead to forward the stderr of the | ||
// esbuild process to the current process's stderr. | ||
stdio?: 'pipe' | 'ignore' | 'inherit' | ('pipe' | 'ignore' | 'inherit' | number | null | undefined)[]; | ||
} | ||
@@ -32,0 +38,0 @@ |
@@ -18,2 +18,3 @@ const child_process = require('child_process'); | ||
const flags = [`--error-limit=${options.errorLimit || 0}`]; | ||
const stdio = options.stdio; | ||
@@ -28,2 +29,3 @@ if (options.name) flags.push(`--name=${options.name}`); | ||
if (options.format) flags.push(`--format=${options.format}`); | ||
if (options.color) flags.push(`--color=${options.color}`); | ||
if (options.external) for (const name of options.external) flags.push(`--external:${name}`); | ||
@@ -46,3 +48,10 @@ | ||
child_process.execFile(binPath, flags, { cwd: process.cwd(), windowsHide: true }, (err, stdout, stderr) => { | ||
const child = child_process.spawn(binPath, flags, { cwd: process.cwd(), windowsHide: true, stdio }); | ||
child.on('error', error => reject(error)); | ||
// The stderr pipe won't be available if "stdio" is set to "inherit" | ||
const stderrChunks = []; | ||
if (child.stderr) child.stderr.on('data', chunk => stderrChunks.push(chunk)); | ||
child.on('close', code => { | ||
const fullRegex = /^(.+):(\d+):(\d+): (warning|error): (.+)$/; | ||
@@ -52,2 +61,3 @@ const smallRegex = /^(warning|error): (.+)$/; | ||
const warnings = []; | ||
const stderr = Buffer.concat(stderrChunks).toString(); | ||
@@ -70,9 +80,10 @@ for (const line of stderr.split('\n')) { | ||
if (errors.length === 0) { | ||
if (err) reject(err); | ||
else resolve({ stderr, warnings }); | ||
if (errors.length === 0 && code === 0) { | ||
resolve({ stderr, warnings }); | ||
} | ||
else { | ||
const error = new Error(`Build failed with ${errors.length} error${errors.length < 2 ? '' : 's'}`); | ||
// The error array will be empty if "stdio" is set to "inherit" | ||
const summary = errors.length < 1 ? '' : ` with ${errors.length} error${errors.length < 2 ? '' : 's'}`; | ||
const error = new Error(`Build failed${summary}`); | ||
error.stderr = stderr; | ||
@@ -83,4 +94,4 @@ error.errors = errors; | ||
} | ||
}).on('error', err => reject(err)); | ||
}) | ||
}); | ||
}); | ||
} |
{ | ||
"name": "esbuild", | ||
"version": "0.1.24", | ||
"version": "0.1.25", | ||
"description": "An extremely fast JavaScript bundler and minifier.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/evanw/esbuild", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9534
201