2016-10-11 11:33:20 +02:00
|
|
|
"use strict";
|
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
const { run } = require( "@futagoza/child-process" );
|
|
|
|
const { series, src, task } = require( "@futagoza/gulpx" );
|
2017-10-25 20:19:42 +02:00
|
|
|
const eslint = require( "gulp-eslint" );
|
|
|
|
const del = require( "del" );
|
2016-10-11 11:33:20 +02:00
|
|
|
|
|
|
|
// Run ESLint on all JavaScript files.
|
2018-10-05 21:32:11 +02:00
|
|
|
task( "lint", () => [
|
2018-03-23 03:00:03 +01:00
|
|
|
|
|
|
|
src( [
|
2017-10-25 20:19:42 +02:00
|
|
|
"**/.*rc.js",
|
2018-09-08 03:39:12 +02:00
|
|
|
"packages/**/*.js",
|
2017-10-25 20:19:42 +02:00
|
|
|
"test/benchmark/**/*.js",
|
|
|
|
"test/benchmark/run",
|
|
|
|
"test/impact",
|
|
|
|
"test/spec/**/*.js",
|
2018-01-19 09:55:04 +01:00
|
|
|
"src/*.js",
|
2018-09-10 05:57:12 +02:00
|
|
|
"rollup.config.js",
|
2018-09-06 06:52:02 +02:00
|
|
|
"gulpfile.js",
|
|
|
|
"server.js",
|
2018-03-23 03:00:03 +01:00
|
|
|
] ),
|
|
|
|
eslint( { dotfiles: true } ),
|
|
|
|
eslint.format(),
|
2018-10-05 21:32:11 +02:00
|
|
|
eslint.failAfterError(),
|
2018-03-23 03:00:03 +01:00
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
] );
|
2016-10-11 11:33:20 +02:00
|
|
|
|
2016-12-08 10:05:17 +01:00
|
|
|
// Run tests.
|
2018-10-05 21:32:11 +02:00
|
|
|
task( "test", () =>
|
2018-03-23 03:00:03 +01:00
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
run( "node node_modules/mocha/bin/mocha test/spec/**/*.spec.js" )
|
2018-03-23 03:00:03 +01:00
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
);
|
2016-10-11 11:33:20 +02:00
|
|
|
|
|
|
|
// Run benchmarks.
|
2018-10-05 21:32:11 +02:00
|
|
|
task( "benchmark", () =>
|
2018-01-07 17:32:33 +01:00
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
run( "node test/benchmark/run" )
|
2018-01-07 17:32:33 +01:00
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
);
|
2016-10-11 11:33:20 +02:00
|
|
|
|
2017-11-28 18:49:51 +01:00
|
|
|
// Generate the grammar parser.
|
2018-10-05 21:32:11 +02:00
|
|
|
task( "build:parser", () =>
|
2018-01-07 17:32:33 +01:00
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
run( "node packages/pegjs/bin/peg -c src/pegjs.config.js" )
|
2018-01-07 17:32:33 +01:00
|
|
|
|
2018-10-05 21:32:11 +02:00
|
|
|
);
|
2017-11-28 18:49:51 +01:00
|
|
|
|
|
|
|
// Delete the generated files.
|
|
|
|
task( "clean", () =>
|
2018-09-10 05:57:12 +02:00
|
|
|
del( [ "packages/pegjs/dist", "website/js/*-bundle.js", "examples/*.js" ] )
|
2016-10-11 11:33:20 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Default task.
|
2018-03-23 03:00:03 +01:00
|
|
|
task( "default", series( "lint", "test" ) );
|