Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop compiling client's code when running gulp watch #1095

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions erizo_controller/erizoClient/gulp/erizoFcTasks.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const webpackConfig = require('../webpack.config.erizofc.js');

const erizoFcTasks = (gulp, plugins, config) => {
const that = {};
if (!config.paths) {
return;
return {};
}
const erizoFcConfig = {
entry: `${config.paths.entry}ErizoFc.js`,
webpackConfig: require('../webpack.config.erizofc.js'),
webpackConfig,
debug: `${config.paths.debug}/erizofc`,
production: `${config.paths.production}/erizofc`,
};
Expand All @@ -16,15 +18,17 @@ const erizoFcTasks = (gulp, plugins, config) => {
.pipe(gulp.dest(erizoFcConfig.debug))
.on('error', anError => console.log('An error ', anError));

that.compile = () => {
return gulp.src(`${erizoFcConfig.debug}/**/*.js`)
that.compile = () => gulp.src(`${erizoFcConfig.debug}/**/*.js`)
.pipe(gulp.dest(erizoFcConfig.production));
}

that.dist = () =>
gulp.src(`${erizoFcConfig.production}/**/*.js`)
.pipe(gulp.dest(config.paths.spine));

that.distDebug = () =>
gulp.src(`${erizoFcConfig.debug}/**/*.js`)
.pipe(gulp.dest(config.paths.spine));

that.clean = () =>
plugins.del([`${erizoFcConfig.debug}/**/*.js*`, `${erizoFcConfig.production}/**/*.js*`],
{ force: true });
Expand Down
10 changes: 8 additions & 2 deletions erizo_controller/erizoClient/gulp/erizoTasks.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const webpackConfig = require('../webpack.config.erizo.js');

const erizoTasks = (gulp, plugins, config) => {
const that = {};
if (!config.paths) {
return;
return that;
}
const erizoConfig = {
entry: `${config.paths.entry}Erizo.js`,
webpackConfig: require('../webpack.config.erizo.js'),
webpackConfig,
debug: `${config.paths.debug}/erizo`,
production: `${config.paths.production}/erizo`,
};
Expand Down Expand Up @@ -33,6 +35,10 @@ const erizoTasks = (gulp, plugins, config) => {
gulp.src(`${erizoConfig.production}/**/*.js*`)
.pipe(gulp.dest(config.paths.basicExample));

that.distDebug = () =>
gulp.src(`${erizoConfig.debug}/**/*.js*`)
.pipe(gulp.dest(config.paths.basicExample));

that.clean = () =>
plugins.del([`${erizoConfig.debug}/**/*.js*`, `${erizoConfig.production}/**/*.js*`],
{ force: true });
Expand Down
39 changes: 20 additions & 19 deletions erizo_controller/erizoClient/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,47 @@ const config = {
};

const tasks = ['clean', 'bundle', 'compile', 'dist'];
const debugTasks = ['clean', 'bundle', 'distDebug'];
const targets = ['erizo', 'erizofc'];
const allTasks = ['lint'];


const taskFunctions = {};
taskFunctions.erizo = require('./gulp/erizoTasks.js')(gulp, plugins, config);
taskFunctions.erizofc = require('./gulp/erizoFcTasks.js')(gulp, plugins, config);

const watchTasks = ['lint'];

const createTasks = (target, targetTasks, sourceTasks) => {
sourceTasks.forEach(
(task) => {
const taskName = `${task}_${target}`;
targetTasks.push(taskName);
gulp.task(taskName, () => taskFunctions[target][task]());
});
};

targets.forEach(
(target) => {
const targetTasks = ['lint'];
tasks.forEach(
(task) => {
const taskName = `${task}_${target}`;
allTasks.push(taskName);
targetTasks.push(taskName);
gulp.task(taskName, () => {
return taskFunctions[target][task]()
});
});
createTasks(target, targetTasks, tasks);
createTasks(target, watchTasks, debugTasks);
gulp.task(target, () => {
plugins.runSequence(...targetTasks);
})
});
});

gulp.task('lint', () => {
return gulp.src(config.paths.js)
gulp.task('lint', () => gulp.src(config.paths.js)
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
.pipe(plugins.eslint.failAfterError());
});
.pipe(plugins.eslint.failAfterError()));

gulp.task('watch', () => {
const watcher = gulp.watch('src/**/*.js');
watcher.on('change', (event) => {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
plugins.runSequence('default');
console.log(`File ${event.path} was ${event.type} running tasks...`);
plugins.runSequence(...watchTasks);
});
});

gulp.task('default', () => {
plugins.runSequence(...allTasks);
plugins.runSequence(...targets);
});