From cefc22a2bd9f8a4f80c674cc651b39b4fc918ea7 Mon Sep 17 00:00:00 2001 From: Joe Lanman Date: Wed, 2 Nov 2016 16:28:09 +0000 Subject: [PATCH] run gulp as child process with logging --- package.json | 2 +- start.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 start.js diff --git a/package.json b/package.json index becc15cc0f..d2aa622846 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "node": ">=4.0 <6.7" }, "scripts": { - "start": "if [ -d \"node_modules\" ]; then gulp; else echo 'gulp is missing - try running npm install' ; fi", + "start": "node start.js", "lint": "standard", "test": "npm run lint" }, diff --git a/start.js b/start.js new file mode 100644 index 0000000000..388de1512f --- /dev/null +++ b/start.js @@ -0,0 +1,23 @@ +// Check for `node_modules` folder and warn if missing + +var path = require('path') +var fs = require('fs') + +if (!fs.existsSync(path.join(__dirname, '/node_modules'))) { + console.error('ERROR: Node module folder missing. Try running `npm install`') + process.exit(0) +} + +// run gulp + +var child = require('child_process') + +process.env['FORCE_COLOR'] = 1 +var gulp = child.spawn('gulp') +gulp.stdout.pipe(process.stdout) +gulp.stderr.pipe(process.stderr) +process.stdin.pipe(gulp.stdin) + +gulp.on('exit', function (code) { + console.log('gulp exited with code ' + code.toString()) +})