Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function server(root, port, livereload) {
var d = Q.defer();
var api = process.env.API_PORT_5000_TCP + '/api' || config.api;
var app = connect();
api = url.parse(api);
// must be present here in the case of using docker compose
api.protocol = 'http:';
api.route = '/api';
if (livereload) {
var options = {host: config.host, port: 35729};
require('gulp-livereload').listen(options, function() {
gutil.log('Livereload started on port:',
gutil.colors.green(options.port));
});
app.use(require('connect-livereload')({port: options.port}));
}
app.use(serveStatic(root));
app.use(proxy(api));
var server = http.createServer(app);
closePromise(server);
server
.on('listening', function() {
var connection = server._connectionKey.split(':');
var address = {
protocol: 'http',
hostname: connection[1],
gulp.task('watch', function() {
// Listen on port 35729
livereload.listen(35729, function (err) {
if (err) {
return console.log(err);
}
gulp.watch([paths.js + '**/*.js'], ['js']);
gulp.watch([paths.scss + '**/*.scss'], ['css']);
});
});
function watch(cb) {
gulp.watch('dev/js/**/*.js', js);
gulp.watch('dev/sass/**/*.scss', css);
// gulp.watch('dev/img/**/*.{jpg,jpeg,png,gif,svg,ico}', img);
livereload.listen();
gulp.watch(['public/*.html', 'public/js/**/*.js', 'public/img/**/*.{jpg,jpeg,png,gif,svg,ico}', 'public/css/*.css']).on('change', livereload.changed);
cb();
}
gulp.watch([path.join(global.paths.build, '**', '*.{html,js,json,css}')]).on('change', function ( file ) {
// report
log('watch '.bgCyan.black, 'reload ' + ('./' + path.relative(global.paths.build, file.path)).bold);
// reload
glr.changed(file);
});
}
gulp.task('watch', ['browserify-watch'], function() {
gulp.watch(options.config.csslint.src, ['csslint']); // .css
gulp.watch(options.config.eslint.src, ['eslint']); // .js or .jsx
gulp.watch(options.config.jshint.src, ['jshint']); // .json
// Start live reload server
livereload.listen(35729);
});
};
function watch() {
livereload.listen();
return gulp.watch(settings.watch, gulp.series(id + ':lint', id + ':build'))
.on('unlink', function(file) {
/*
var relpath = path.relative(path.resolve('src'), file),
resolved = path.resolve('build', relpath);
console.log(file, relpath, resolved);
*/
//del.sync(resolved);
});
}
function watch() {
livereload.listen();
return gulp.watch(settings.watch, gulp.series(id + ':lint', id + ':build'))
.on('unlink', function(file) {
/*
var relpath = path.relative(path.resolve('src'), file),
resolved = path.resolve('build', relpath);
console.log(file, relpath, resolved);
*/
//del.sync(resolved);
});
}
]).on('change', function(file){
//console.log(file.path + ' changed')
livereload.changed(file)
});
this.stdout.on('data', function (chunk) {
if(/^Express server listening on port/.test(chunk)){
livereload.changed(__dirname);
}
});
this.stdout.pipe(process.stdout);
this.stdout.on("data", function(chunk) {
if (/^Express server listening on port/.test(chunk)) {
livereload.changed(__dirname);
}
});
this.stdout.pipe(process.stdout);