obj2gltf/gulpfile.js

84 lines
2.7 KiB
JavaScript
Raw Normal View History

2016-06-09 13:33:08 -04:00
'use strict';
2016-07-08 18:10:18 -04:00
var Cesium = require('cesium');
var child_process = require('child_process');
var fsExtra = require('fs-extra');
2016-06-09 13:33:08 -04:00
var gulp = require('gulp');
var eslint = require('gulp-eslint');
2016-07-08 18:10:18 -04:00
var Jasmine = require('jasmine');
2017-03-13 15:28:51 -04:00
var JasmineSpecReporter = require('jasmine-spec-reporter').SpecReporter;
2016-07-08 18:10:18 -04:00
var open = require('open');
var path = require('path');
var yargs = require('yargs');
2016-06-09 13:33:08 -04:00
2016-07-08 18:10:18 -04:00
var defined = Cesium.defined;
var argv = yargs.argv;
2016-06-09 13:33:08 -04:00
2016-07-08 18:10:18 -04:00
// Add third-party node module binaries to the system path
// since some tasks need to call them directly.
var environmentSeparator = process.platform === 'win32' ? ';' : ':';
var nodeBinaries = path.join(__dirname, 'node_modules', '.bin');
process.env.PATH += environmentSeparator + nodeBinaries;
2016-06-09 13:33:08 -04:00
var esLintFiles = ['**/*.js', '!node_modules/**', '!coverage/**', '!doc/**'];
2017-03-13 15:28:51 -04:00
var specFiles = ['**/*.js', '!node_modules/**', '!coverage/**', '!doc/**', '!bin/**'];
2016-07-08 18:10:18 -04:00
gulp.task('eslint', function () {
var stream = gulp.src(esLintFiles)
.pipe(eslint())
.pipe(eslint.format());
2016-07-08 18:10:18 -04:00
if (argv.failTaskOnError) {
stream = stream.pipe(eslint.failAfterError());
2016-07-08 18:10:18 -04:00
}
return stream;
});
gulp.task('eslint-watch', function() {
gulp.watch(esLintFiles).on('change', function(event) {
gulp.src(event.path)
.pipe(eslint())
.pipe(eslint.format());
});
2016-07-08 18:10:18 -04:00
});
gulp.task('test', function (done) {
var jasmine = new Jasmine();
jasmine.loadConfigFile('specs/jasmine.json');
jasmine.addReporter(new JasmineSpecReporter({
displaySuccessfulSpec: !defined(argv.suppressPassed) || !argv.suppressPassed
}));
jasmine.execute();
jasmine.onComplete(function (passed) {
done(argv.failTaskOnError && !passed ? 1 : 0);
});
2016-06-09 13:33:08 -04:00
});
2016-07-08 18:10:18 -04:00
gulp.task('test-watch', function () {
gulp.watch(specFiles).on('change', function () {
2017-03-13 15:28:51 -04:00
// We can't simply depend on the test task because Jasmine
// does not like being run multiple times in the same process.
2016-07-08 18:10:18 -04:00
try {
child_process.execSync('jasmine JASMINE_CONFIG_PATH=specs/jasmine.json', {
stdio: [process.stdin, process.stdout, process.stderr]
});
} catch (exception) {
console.log('Tests failed to execute.');
}
2016-06-09 13:33:08 -04:00
});
});
2016-07-08 18:10:18 -04:00
gulp.task('coverage', function () {
fsExtra.removeSync('coverage/server');
child_process.execSync('istanbul' +
' cover' +
' --include-all-sources' +
' --dir coverage' +
2017-03-13 15:28:51 -04:00
' -x "specs/**" -x "coverage/**" -x "doc/**" -x "bin/**" -x "index.js" -x "gulpfile.js"' +
2016-07-08 18:10:18 -04:00
' node_modules/jasmine/bin/jasmine.js' +
' JASMINE_CONFIG_PATH=specs/jasmine.json', {
stdio: [process.stdin, process.stdout, process.stderr]
});
open('coverage/lcov-report/index.html');
});