Skip to content

Commit

Permalink
chore: switch to gulp 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhus committed Apr 9, 2020
1 parent 8f1a093 commit 6e3f843
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
70 changes: 35 additions & 35 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,37 @@ gulp.task('build:es6', done => {
.on('end', () => done());
});

/**
* Clean-ups files from previous build.
*
* @task {clean}
* @order {1}
*/
gulp.task('clean', done => {
rimraf('gauge.js', () =>
rimraf('gauge.min.js', () =>
rimraf('gauge.min.js.map', () =>
rimraf('gauge.min.js.gz', done))));
});

/**
* Cleans docs directory
*
* @task {clean:docs}
* @order {6}
*/
gulp.task('clean:docs', done => {
rimraf('docs', done);
});

/**
* Builds and minifies es5 code
*
* @task {build:es5}
* @arg {type} build type: 'radial' - Gauge object only, 'linear' - LinearGauge object only, 'all' - everything (default)
* @order {3}
*/
gulp.task('build:es5', ['clean'], done => {
gulp.task('build:es5', gulp.series('clean', done => {
es5transpile(yargs.argv.type || 'all')
.pipe(gulp.dest('.'))
.on('end', () => {
Expand All @@ -329,30 +352,7 @@ gulp.task('build:es5', ['clean'], done => {

done();
});
});

/**
* Clean-ups files from previous build.
*
* @task {clean}
* @order {1}
*/
gulp.task('clean', done => {
rimraf('gauge.js', () =>
rimraf('gauge.min.js', () =>
rimraf('gauge.min.js.map', () =>
rimraf('gauge.min.js.gz', done))));
});

/**
* Cleans docs directory
*
* @task {clean:docs}
* @order {6}
*/
gulp.task('clean:docs', done => {
rimraf('docs', done);
});
}));

/**
* Automatically generates API documentation for this project
Expand All @@ -361,7 +361,7 @@ gulp.task('clean:docs', done => {
* @task {doc}
* @order {7}
*/
gulp.task('doc', ['clean:docs'], done => {
gulp.task('doc', gulp.series('clean:docs', done => {
gulp.src('./lib')
.pipe(esdoc({
destination: './docs',
Expand Down Expand Up @@ -404,7 +404,7 @@ gulp.task('doc', ['clean:docs'], done => {

rimraf(target, () => fs.rename('docs', target, done));
});
});
}));

/**
* Transpiles, combines and minifies JavaScript code.
Expand All @@ -425,23 +425,23 @@ gulp.task('build', () => {
*
* @task {watch}
*/
gulp.task('watch', ['build'], () => {
gulp.task('watch', gulp.series('build', () => {
gulp.watch('lib/**/*.js', () => gulp.start('build'));
});
}));

/**
* Runs gzipping for minified file.
*
* @task {gzip}
*/
gulp.task('gzip', ['build:prod'], done => {
gulp.task('gzip', gulp.series('build:prod', done => {
Promise.all(types.map(type => new Promise(resolve => {
gulp.src('dist/' + type + '/gauge.min.js')
.pipe(gzip({ gzipOptions: { level: 9 } }))
.pipe(gulp.dest('dist/' + type))
.on('end', resolve);
}))).then(() => done());
});
}));

/**
* Performs JavaScript syntax check.
Expand Down Expand Up @@ -564,7 +564,7 @@ gulp.task('selenium', done => {
* drawing, most probably expected pixels won't match the expected specs,
* so we can automatically figure something is broken.
*/
gulp.task('test:e2e', ['selenium'], done => {
gulp.task('test:e2e', gulp.series('selenium', done => {
console.log(chalk.bold.green('\nStarting end-to-end tests...\n'));

gulp.src(['test/e2e/**/*.e2e.js'])
Expand All @@ -578,13 +578,13 @@ gulp.task('test:e2e', ['selenium'], done => {
cp.execSync('pkill -f selenium-standalone');
done();
});
});
}));

/**
* Runs all tests and checks.
*
* @task {test}
*/
gulp.task('test', ['lint', 'test:spec'/*, 'test:e2e'*/]);
gulp.task('test', gulp.series('lint', 'test:spec'/*, 'test:e2e'*/));

gulp.task('default', ['help']);
gulp.task('default', gulp.series('help'));
9 changes: 5 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = config => {
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
'Chrome',
'Firefox'
// 'Firefox',
],

customLaunchers: {
Expand All @@ -107,8 +107,6 @@ module.exports = config => {
}
},



// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
Expand All @@ -119,7 +117,10 @@ module.exports = config => {
};

if (process.env.TRAVIS) {
options.browsers = ['ChromeTravis', 'Firefox'];
options.browsers = [
'ChromeTravis',
// 'Firefox',
];
}

config.set(options);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"chalk": "^1.1.3",
"eslint": "^3.3.1",
"fs-cli": "^0.1.1",
"gulp": "^3.9.1",
"gulp": "^4.0.2",
"gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-esdoc": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion test-coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6e3f843

Please sign in to comment.