Merge pull request #1879 from MetaMask/build-err-fix

Build sys - prevent err from being swallowed
feature/default_network_editable
Thomas Huang 7 years ago committed by GitHub
commit 02a6cd255b
  1. 43
      gulpfile.js
  2. 4
      package.json

@ -248,26 +248,27 @@ function zipTask(target) {
} }
} }
function generateBundler(opts) { function generateBundler(opts, performBundle) {
var browserifyOpts = assign({}, watchify.args, { const browserifyOpts = assign({}, watchify.args, {
entries: ['./app/scripts/'+opts.filename], entries: ['./app/scripts/'+opts.filename],
plugin: 'browserify-derequire', plugin: 'browserify-derequire',
debug: debug, debug: debug,
fullPaths: debug, fullPaths: debug,
}) })
return browserify(browserifyOpts) let bundler = browserify(browserifyOpts)
}
function discTask(opts) {
let bundler = generateBundler(opts)
if (opts.watch) { if (opts.watch) {
bundler = watchify(bundler) bundler = watchify(bundler)
// on any dep update, runs the bundler // on any file update, re-runs the bundler
bundler.on('update', performBundle) bundler.on('update', performBundle)
} }
return bundler
}
function discTask(opts) {
const bundler = generateBundler(opts, performBundle)
// output build logs to terminal // output build logs to terminal
bundler.on('log', gutil.log) bundler.on('log', gutil.log)
@ -289,14 +290,7 @@ function discTask(opts) {
function bundleTask(opts) { function bundleTask(opts) {
let bundler = generateBundler(opts) const bundler = generateBundler(opts, performBundle)
if (opts.watch) {
bundler = watchify(bundler)
// on any file update, re-runs the bundler
bundler.on('update', performBundle)
}
// output build logs to terminal // output build logs to terminal
bundler.on('log', gutil.log) bundler.on('log', gutil.log)
@ -306,6 +300,17 @@ function bundleTask(opts) {
return ( return (
bundler.bundle() bundler.bundle()
// handle errors
.on('error', (err) => {
beep()
if (opts.watch) {
console.warn(err.stack)
} else {
throw err
}
})
// convert bundle stream to gulp vinyl stream // convert bundle stream to gulp vinyl stream
.pipe(source(opts.filename)) .pipe(source(opts.filename))
// inject variables into bundle // inject variables into bundle
@ -314,7 +319,7 @@ function bundleTask(opts) {
.pipe(buffer()) .pipe(buffer())
// sourcemaps // sourcemaps
// loads map from browserify file // loads map from browserify file
.pipe(gulpif(debug, sourcemaps.init({loadMaps: true}))) .pipe(gulpif(debug, sourcemaps.init({ loadMaps: true })))
// writes .map file // writes .map file
.pipe(gulpif(debug, sourcemaps.write('./'))) .pipe(gulpif(debug, sourcemaps.write('./')))
// write completed bundles // write completed bundles
@ -328,3 +333,7 @@ function bundleTask(opts) {
) )
} }
} }
function beep () {
process.stdout.write('\x07')
}

@ -155,8 +155,8 @@
"enzyme": "^2.8.2", "enzyme": "^2.8.2",
"eslint-plugin-chai": "0.0.1", "eslint-plugin-chai": "0.0.1",
"eslint-plugin-mocha": "^4.9.0", "eslint-plugin-mocha": "^4.9.0",
"fs-promise": "^2.0.3",
"eth-json-rpc-middleware": "^1.2.7", "eth-json-rpc-middleware": "^1.2.7",
"fs-promise": "^2.0.3",
"gulp": "github:gulpjs/gulp#4.0", "gulp": "github:gulpjs/gulp#4.0",
"gulp-if": "^2.0.1", "gulp-if": "^2.0.1",
"gulp-json-editor": "^2.2.1", "gulp-json-editor": "^2.2.1",
@ -191,7 +191,7 @@
"uglifyify": "^4.0.2", "uglifyify": "^4.0.2",
"vinyl-buffer": "^1.0.0", "vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0", "vinyl-source-stream": "^1.1.0",
"watchify": "^3.7.0" "watchify": "^3.9.0"
}, },
"engines": { "engines": {
"node": ">=0.8.0" "node": ">=0.8.0"

Loading…
Cancel
Save