Tone.js/gulp/gulpfile.js

78 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-05-18 17:55:32 +00:00
const gulp = require("gulp");
const glob = require("glob");
const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");
2018-05-18 16:12:41 +00:00
const eslint = require("gulp-eslint");
const coveralls = require("gulp-coveralls");
const argv = require("yargs")
2018-05-18 22:03:11 +00:00
.alias("i", "file")
.alias("d", "dir")
2017-12-30 16:26:29 +00:00
.argv;
2015-05-23 22:14:03 +00:00
/**
2018-05-19 18:30:50 +00:00
* COLLECT DEPENDENCIES
2015-05-23 22:14:03 +00:00
*/
2018-05-18 16:12:41 +00:00
gulp.task("collectDependencies", function(done){
2018-05-19 18:30:50 +00:00
//collect all of the files into one file prefixed with 'require'
2016-09-30 04:42:18 +00:00
glob("../Tone/*/*.js", function(err, files){
var modules = [];
2018-05-18 17:55:32 +00:00
// gutil.log(gutil.colors.magenta("files found:", files.length));
2016-09-30 04:42:18 +00:00
files.forEach(function(file){
//remove the precedding ../ and the trailing .js
var module = file.substring(3, file.length - 3);
2018-05-18 16:12:41 +00:00
if (module !== "Tone/core/Tone"){
modules.push(module);
}
2015-05-23 22:14:03 +00:00
});
2016-09-30 04:42:18 +00:00
//write it to disk
2018-05-18 16:12:41 +00:00
var reqString = modules.map(r => `require("${r}");`).join("\n");
reqString += "\nmodule.exports = require(\"Tone/core/Tone\");\n";
fs.writeFile("../Tone/index.js", reqString, done);
2015-05-23 22:14:03 +00:00
});
});
2018-05-19 18:30:50 +00:00
/**
* COLLECT TESTS
*/
gulp.task("collectTests", function(done){
var tests = "../test/!(helper|deps|examples)/*.js";
if (argv.file){
tests = `../test/*/${argv.file}.js`;
} else if (argv.dir){
tests = `../test/${argv.dir}/*.js`;
}
glob(tests, (err, files) => {
var reqString = files.map(r => `require("${r}");`).join("\n");
fs.writeFile("../test/test.js", reqString, done);
});
});
2016-11-07 00:40:32 +00:00
/**
* LINTING
*/
2018-05-18 16:12:41 +00:00
gulp.task("lint", function(){
2016-11-07 00:40:32 +00:00
return gulp.src("../Tone/*/*.js")
2017-10-26 19:10:52 +00:00
.pipe(eslint())
.pipe(eslint.format())
2017-12-30 16:26:29 +00:00
.pipe(eslint.failAfterError());
2017-10-26 19:10:52 +00:00
});
2018-05-18 16:12:41 +00:00
gulp.task("lint-fix", function(){
2017-10-26 19:10:52 +00:00
return gulp.src("../Tone/*/*.js")
.pipe(eslint({
fix : true
}))
.pipe(eslint.format())
2017-12-30 16:26:29 +00:00
.pipe(eslint.failAfterError())
2017-10-26 19:10:52 +00:00
.pipe(gulp.dest("../Tone"));
2016-11-07 00:40:32 +00:00
});
2017-04-30 17:02:35 +00:00
/**
* COVERALLS
*/
gulp.task("coveralls", function(){
return gulp.src("../test/coverage/**/lcov.info")
.pipe(coveralls());
2017-08-08 17:29:58 +00:00
});