Skip to content

Commit

Permalink
fix(scripts): add livereload
Browse files Browse the repository at this point in the history
  • Loading branch information
joaogarin authored Jun 11, 2021
2 parents 5bfb0ae + 76f0eb8 commit d7c01d1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
1 change: 1 addition & 0 deletions bin/recruiter-epiq-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ case 'watch':
case 'images':
case 'styleguide':
case 'critical':
case 'livereload':
var result = spawn.sync(
'node',
[require.resolve('../scripts/' + script)].concat(args),
Expand Down
13 changes: 7 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gulpConfigDefault = "../../gulpconfig.json";
paths = {
sass: ["../../src/sass/**/*.scss"],
images: ["../../src/images/**/*"],
livereload: ["../../dist/*"],
docs: "docs",
styleguide: {
docs: "../../styleguide/docs",
Expand Down Expand Up @@ -79,15 +80,15 @@ gulp.task("svg-icons", function () {
gulp.task("livereload", function () {
var livereload;
livereload = require("gulp-livereload");
livereload.changed();
livereload.listen();
gulp.watch(paths.livereload).on('all', function(event, path, stats) {
livereload.changed(path);
});
});

gulp.task("watch", function () {
var livereload;
livereload = require("gulp-livereload");
livereload.listen();
gulp.watch(paths.sass, gulp.series("sass", "livereload"));
return gulp.watch(paths.images, gulp.series("images", "livereload"));
gulp.watch(paths.sass, gulp.series("sass"));
return gulp.watch(paths.images, gulp.series("images"));
});

gulp.task("build", gulp.series("images", "sass", "svg-icons"));
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"gulp-changed": "^4.0.0",
"gulp-concat": "~2.6.1",
"gulp-imagemin": "^7.1.0",
"gulp-livereload": "^3.8.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^1.0.0",
"gulp-rimraf": "^0.2.1",
Expand Down
24 changes: 24 additions & 0 deletions scripts/livereload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var spawn = require('child_process').spawn,
chalk = require('chalk');

var options = {cwd: 'node_modules/recruiter_epiq_deps'};

console.log('Running livereload script - ' + chalk.yellow('gulp livereload'));

var livereload = spawn('gulp', ['livereload', 'default'], options);

livereload.stdout.on('data', function (data) {
console.log(chalk.green(data));
});

livereload.stderr.on('data', function (data) {
console.log(chalk.red(data));
});

livereload.on('close', function (data) {
console.log(chalk.white(data));
});

livereload.on('error', function (err) {
console.log(chalk.red(err));
});
4 changes: 2 additions & 2 deletions scripts/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var options = {cwd: 'node_modules/recruiter_epiq_deps'};

console.log('Running watch script - ' + chalk.yellow('gulp watch'));

var watch = spawn('gulp', options, ['watch']);
var watch = spawn('gulp', ['watch'], options);

watch.stdout.on('data', function (data) {
console.log(chalk.green(data));
Expand All @@ -21,4 +21,4 @@ watch.on('close', function (data) {

watch.on('error', function (err) {
console.log(chalk.red(err));
});
});

0 comments on commit d7c01d1

Please sign in to comment.