X-Git-Url: https://git.proxmox.com/?p=mirror_xterm.js.git;a=blobdiff_plain;f=gulpfile.js;h=249b7a0fa3434300532178dbba02139028ec759e;hp=c9a0f1a0d465c2004ca9f9a1f7968a53792d479a;hb=HEAD;hpb=c62923fb1de4318eb79d76c398053c15fca7734b diff --git a/gulpfile.js b/gulpfile.js index c9a0f1a..249b7a0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,7 @@ const browserify = require('browserify'); const buffer = require('vinyl-buffer'); const coveralls = require('gulp-coveralls'); const fs = require('fs-extra'); +const path = require('path'); const gulp = require('gulp'); const istanbul = require('gulp-istanbul'); const merge = require('merge-stream'); @@ -14,7 +15,7 @@ const sorcery = require('sorcery'); const source = require('vinyl-source-stream'); const sourcemaps = require('gulp-sourcemaps'); const ts = require('gulp-typescript'); - +const util = require('gulp-util'); let buildDir = process.env.BUILD_DIR || 'build'; let tsProject = ts.createProject('tsconfig.json'); @@ -22,6 +23,12 @@ let tsProjectSearchAddon = ts.createProject('./src/addons/search/tsconfig.json') let srcDir = tsProject.config.compilerOptions.rootDir; let outDir = tsProject.config.compilerOptions.outDir; +// Under some environments like TravisCI, this comes out at absolute which can +// break the build. This ensures that the outDir is absolute. +if (outDir.indexOf(__dirname) !== 0) { + outDir = `${__dirname}/${outDir}`; +} + /** * Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript * file compiled. @@ -82,13 +89,14 @@ gulp.task('browserify-addons', ['tsc'], function() { let searchOptions = { basedir: `${buildDir}/addons/search`, debug: true, - entries: [`${outDir}/addons/search/Search.js`], + entries: [`${outDir}/addons/search/search.js`], cache: {}, packageCache: {} }; let searchBundle = browserify(searchOptions) + .external(path.join(outDir, 'xterm.js')) .bundle() - .pipe(source('./addons/search/Search.js')) + .pipe(source('./addons/search/search.js')) .pipe(buffer()) .pipe(sourcemaps.init({loadMaps: true, sourceRoot: ''})) .pipe(sourcemaps.write('./')) @@ -121,13 +129,26 @@ gulp.task('mocha', ['instrument-test'], function () { .pipe(istanbul.writeReports()); }); +/** + * Run single test file by file name(without file extension). Example of the command: + * gulp mocha-test --test InputHandler.test + */ +gulp.task('mocha-test', ['instrument-test'], function () { + let testName = util.env.test; + util.log("Run test by Name: " + testName); + return gulp.src([`${outDir}/${testName}.js`, `${outDir}/**/${testName}.js`], {read: false}) + .pipe(mocha()) + .once('error', () => process.exit(1)) + .pipe(istanbul.writeReports()); +}); + /** * Use `sorcery` to resolve the source map chain and point back to the TypeScript files. * (Without this task the source maps produced for the JavaScript bundle points into the * compiled JavaScript files in ${outDir}/). */ gulp.task('sorcery', ['browserify'], function () { - var chain = sorcery.loadSync(`${buildDir}/xterm.js`); + let chain = sorcery.loadSync(`${buildDir}/xterm.js`); chain.apply(); chain.writeSync(); });