diff --git a/.gitignore b/.gitignore index f51ea0c4..9b8b187d 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ examples/deps/Tone.dat.gui.js examples/deps/dat.gui.js test/mainTest.js + +test/Main.js diff --git a/gulp/fragments/test.frag b/gulp/fragments/test.frag index 29a94b10..7f51c548 100644 --- a/gulp/fragments/test.frag +++ b/gulp/fragments/test.frag @@ -2,6 +2,7 @@ require.config({ baseUrl:"./", paths : { "Tone" : "../Tone", + "Test" : "helper/Test" }, }); diff --git a/gulp/gulpfile.js b/gulp/gulpfile.js index 362f74e0..5ed3c0e3 100644 --- a/gulp/gulpfile.js +++ b/gulp/gulpfile.js @@ -12,7 +12,18 @@ var uglify = require("gulp-uglify"); var rename = require("gulp-rename"); var sass = require("gulp-ruby-sass"); var prefix = require("gulp-autoprefixer"); -var open = require("gulp-open"); +var openFile = require("gulp-open"); +var argv = require("yargs") + .alias("f", "file") + .alias("s", "signal") + .alias("i", "instrument") + .alias("o", "source") + .alias("t", "structure") + .alias("e", "effect") + .alias("c", "core") + .alias("m", "component") + .argv; +var webserver = require("gulp-webserver"); /** * BUILDING @@ -111,18 +122,59 @@ gulp.task("example", function() { gulp.watch(["../examples/style/examples.scss"], ["sass"]); }); +/** + * THE WEBSERVER + */ +gulp.task("server", function(){ + gulp.src("../") + .pipe(webserver({ + // livereload: false, + directoryListing: true, + port : 3000, + open: false + })); +}); /** - * Test Runners + * TEST RUNNER */ -gulp.task("test", ["collectTests"], function(){ - gulp.src("../test/test.html") - .pipe(open()); +gulp.task("test", ["server", "collectTests"], function(){ + gulp.src("../test/index.html") + .pipe(openFile({uri: "http://localhost:3000/test"})); }); gulp.task("collectTests", function(done){ + var tests = ["../test/*/*.js", "!../test/helper/*.js", "!../test/tests/*.js"]; + if (argv.file){ + tests = ["../test/*/"+argv.file+".js"]; + } else if (argv.signal || argv.core || argv.component || argv.instrument || + argv.source || argv.effect || argv.structure){ + tests = []; + if (argv.signal){ + tests.push("../test/signal/*.js"); + } + if (argv.core){ + tests.push("../test/core/*.js"); + } + if (argv.source){ + tests.push("../test/source/*.js"); + } + if (argv.instrument){ + tests.push("../test/instrument/*.js"); + } + if (argv.component){ + tests.push("../test/component/*.js"); + } + if (argv.effect){ + tests.push("../test/effect/*.js"); + } + if (argv.structure){ + tests.push("../test/structure/*.js"); + } + } + // console.log(argv.signal === undefined); var allFiles = []; - var task = gulp.src(["../test/Test/*/*.js"]) + var task = gulp.src(tests) .pipe(tap(function(file){ var fileName = path.relative("../test/", file.path); allFiles.push(fileName.substring(0, fileName.length - 3)); @@ -132,7 +184,7 @@ gulp.task("collectTests", function(done){ allFiles.unshift("Test"); var innerTask = gulp.src("./fragments/test.frag") .pipe(replace("{FILES}", JSON.stringify(allFiles))) - .pipe(rename("mainTest.js")) + .pipe(rename("Main.js")) .pipe(gulp.dest("../test/")); innerTask.on("end", done); }); diff --git a/gulp/package.json b/gulp/package.json index c12f2a8d..495b4c4f 100644 --- a/gulp/package.json +++ b/gulp/package.json @@ -4,19 +4,22 @@ "description": "gulp build system for Tone.js", "main": "gulpfile.js", "dependencies": { - "gulp": "^3.8.11", - "del": "^1.1.1", "amd-optimize": "^0.4.3", + "del": "^1.1.1", + "gulp": "^3.8.11", + "gulp-autoprefixer": "^2.3.1", "gulp-concat": "^2.5.2", + "gulp-concat-css": "^2.2.0", "gulp-indent": "^1.0.0", "gulp-insert": "^0.4.0", - "gulp-tap": "^0.1.3", - "gulp-replace": "^0.5.3", - "gulp-uglify": "^1.2.0", + "gulp-open": "^1.0.0", "gulp-rename": "^1.2.2", - "gulp-autoprefixer": "^2.3.1", - "gulp-concat-css": "^2.2.0", - "gulp-ruby-sass": "^1.0.5" + "gulp-replace": "^0.5.3", + "gulp-ruby-sass": "^1.0.5", + "gulp-tap": "^0.1.3", + "gulp-uglify": "^1.2.0", + "gulp-webserver": "^0.9.1", + "yargs": "^3.21.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -27,8 +30,5 @@ "Tone.js" ], "author": "Yotam Mann", - "license": "MIT", - "devDependencies": { - "gulp-open": "^1.0.0" - } + "license": "MIT" }