You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/ui/build/runGulp.js

34 lines
983 B
JavaScript

5 years ago
/* eslint-disable import/no-extraneous-dependencies */
5 years ago
import gulp from 'gulp';
import log from 'fancy-log';
import chalk from 'chalk';
5 years ago
import gulpConfig from './config/gulp';
5 years ago
export default async function ({ watch, production }) {
function handleError(err) {
log(chalk.red('Error: %s'), chalk.reset(err.toString()));
if (err && !watch) { process.exit(1); }
}
const gulpTasks = gulpConfig({ watch, production, errorHandler: handleError });
return new Promise((resolve) => {
const taskList = {};
gulp.on('start', ({ uid, name }) => {
log(chalk.blue('Starting task: %s'), chalk.reset(name));
taskList[uid] = true;
});
gulp.on('stop', ({ uid, name }) => {
log(chalk.green('Finished: %s'), chalk.reset(name));
taskList[uid] = false;
if (Object.values(taskList).filter((b) => b).length === 0) {
5 years ago
if (watch) {
gulpTasks.watch();
}
resolve();
}
});
gulpTasks.default();
});
}