const gulp = require('gulp');
const less = require('gulp-less');

function onError(err) {
  util.log(util.colors.red.bold('[ERROR LESS]:'),util.colors.bgRed(err.message));
  this.emit('end');
};

/* ----------------------------------------- */
/*  Compile LESS
/* ----------------------------------------- */
function compileLESS() {
  return gulp.src("styles/fvtt-cthulhu-eternal.less")
      .pipe(less()).on('error',console.log.bind(console))
      .pipe(gulp.dest("./css"))
}
const css = gulp.series(compileLESS);

/* ----------------------------------------- */
/*  Watch Updates
/* ----------------------------------------- */
const SIMPLE_LESS = ["styles/*.less"];

function watchUpdates() {
  gulp.watch(SIMPLE_LESS, css);
}

/* ----------------------------------------- */
/*  Export Tasks
/* ----------------------------------------- */

exports.default = gulp.series(
    gulp.parallel(css),
    watchUpdates
);
exports.css = css;
exports.watchUpdates = watchUpdates;
