Open heran opened 9 years ago
I have this working with an express-generator skeleton. I don't really know what I'm doing, so it may not be "correct", but it works.
var gulp = require('gulp');
var gls = require('gulp-live-server');
gulp.task('serve', function() {
var server = gls.new('bin/www', {env: {NODE_ENV: 'development'}});
server.start();
gulp.watch(['views/*', 'public/**/*'], function (file) {
server.notify.apply(server, [file]);
});
gulp.watch(['bin/www', 'app.js', 'routes/*'], function (file) {
server.start.apply(server);
server.notify.apply(server, [file]);
})
});
My code, not work:
var path = require('path-extra');
var server = gls(path.join(__dirname, 'bin/www') , {env: {NODE_ENV: 'development'}});
server.start();
gulp.watch(['app/**'], function (file) {
server.notify.apply(server, [file]);
console.log('brower reload');
});
I must patch gls/index.js
, line 132
this.config.execPath = (util.isString(execPath)?execPath:false) || this.config.execPath || process.execPath;
gulpfile.js:
gulp.watch('some.file.ext', server.start.bind(server));
gls/index.js:
exports.start = function (execPath) {...this.server = spawn(this.config.execPath, this.config.args, this.config.options);...}
execPath will be:
{type: evt, path: path}
come from glob-watched/index.js:
then get the spawn error: