diff --git a/gulpfile.js b/gulpfile.js index af4fdce0..8fe5bf9c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,7 +20,7 @@ const webpack = require('webpack-stream'); const buildDir = process.env.BUILD_DIR || 'build'; const tsProject = ts.createProject('tsconfig.json'); -const srcDir = tsProject.config.compilerOptions.rootDir; +let srcDir = tsProject.config.compilerOptions.rootDir; let outDir = tsProject.config.compilerOptions.outDir; const addons = fs.readdirSync(`${__dirname}/src/addons`); @@ -31,58 +31,19 @@ if (path.normalize(outDir).indexOf(__dirname) !== 0) { outDir = `${__dirname}/${path.normalize(outDir)}`; } -/** - * Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript - * file compiled. - */ -gulp.task('tsc', function () { - // Remove the ${outDir}/ directory to prevent confusion if files were deleted in ${srcDir}/ - fs.emptyDirSync(`${outDir}`); +gulp.task('css', function() { + return gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir)); +}); - // Build all TypeScript files (including tests) to ${outDir}/, based on the configuration defined in - // `tsconfig.json`. - let tsResult = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject()); - let tsc = merge( - tsResult.js.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir)), - tsResult.dts.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir)) - ); - - let addonStreams = addons.map(function(addon) { - fs.emptyDirSync(`${outDir}/addons/${addon}`); - - let tsProjectAddon = ts.createProject(`./src/addons/${addon}/tsconfig.json`); - let tsResultAddon = tsProjectAddon.src().pipe(sourcemaps.init()).pipe(tsProjectAddon()); - let tscAddon = merge( - tsResultAddon.js - .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})) - .pipe(gulp.dest(`${outDir}/addons/${addon}`)), - tsResultAddon.dts - .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})) - .pipe(gulp.dest(`${outDir}/addons/${addon}`)) - ) - - return tscAddon; - }); - - // Copy all addons from ${srcDir}/ to ${outDir}/ - let copyAddons = gulp.src([ - `${srcDir}/addons/**/**` - ]).pipe(gulp.dest(`${outDir}/addons`)); - - // Copy stylesheets from ${srcDir}/ to ${outDir}/ - let copyStylesheets = gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir)); - - // Join all streams into a single array - let streams = [tsc].concat(addonStreams).concat([copyAddons, copyStylesheets]); - - return merge.apply(this, streams); +gulp.task('watch-css', function() { + return gulp.watch(`${srcDir}/**/*.css`, ['css']); }); /** * Bundle JavaScript files produced by the `tsc` task, into a single file named `xterm.js` with * Browserify. */ -gulp.task('browserify', ['tsc'], function() { +gulp.task('browserify', function() { // Ensure that the build directory exists fs.ensureDirSync(buildDir); @@ -108,7 +69,7 @@ gulp.task('browserify', ['tsc'], function() { return merge(bundleStream, copyStylesheets); }); -gulp.task('browserify-addons', ['tsc'], function() { +gulp.task('browserify-addons', function() { const bundles = addons.map((addon) => { const addonOptions = { basedir: `${buildDir}/addons/${addon}`, @@ -192,8 +153,9 @@ gulp.task('webpack', ['build'], function() { .pipe(gulp.dest('demo/dist/')); }); -gulp.task('watch', ['webpack'], () => { - gulp.watch(['./src/*', './src/**/*'], ['webpack']); + +gulp.task('watch-demo', ['webpack'], () => { + gulp.watch(['./demo/*', './lib/**/*'], ['webpack']); }); /** diff --git a/package.json b/package.json index 5c7574ee..54c93e62 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "@types/jsdom": "^11.0.1", "@types/mocha": "^2.2.33", "@types/node": "6.0.108", - "@types/text-encoding": "0.0.32", "browserify": "^13.3.0", "chai": "3.5.0", + "concurrently": "^3.5.1", "express": "4.13.4", "express-ws": "2.0.0-rc.1", "fs-extra": "^1.0.0", @@ -37,7 +37,7 @@ "sorcery": "^0.10.0", "tslint": "^5.9.1", "tslint-consistent-codestyle": "^1.13.0", - "typescript": "~2.7.1", + "typescript": "2.8.3", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "webpack": "^3.10.0", @@ -45,17 +45,18 @@ "zmodem.js": "^0.1.5" }, "scripts": { - "start": "node demo/app", + "start": "concurrently --kill-others-on-fail --names 'demo,server' 'gulp watch-demo' 'node demo/app'", "start-zmodem": "node demo/zmodem/app", "lint": "tslint 'src/**/*.ts'", "test": "npm-run-all mocha lint", "mocha": "gulp test", "build:docs": "jsdoc -c jsdoc.json", "tsc": "tsc", + "prebuild": "concurrently --kill-others-on-fail --names \"lib,attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem,css\" \"tsc\" \"tsc -p ./src/addons/attach\" \"tsc -p ./src/addons/fit\" \"tsc -p ./src/addons/fullscreen\" \"tsc -p ./src/addons/search\" \"tsc -p ./src/addons/terminado\" \"tsc -p ./src/addons/webLinks\" \"tsc -p ./src/addons/winptyCompat\" \"tsc -p ./src/addons/zmodem\" \"gulp css\"", "build": "gulp build", "prepublish": "npm run build", "coveralls": "gulp coveralls", "webpack": "gulp webpack", - "watch": "gulp watch" + "watch": "concurrently --kill-others-on-fail --names \"lib,attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem,css\" \"tsc -w\" \"tsc -w -p ./src/addons/attach\" \"tsc -w -p ./src/addons/fit\" \"tsc -w -p ./src/addons/fullscreen\" \"tsc -w -p ./src/addons/search\" \"tsc -w -p ./src/addons/terminado\" \"tsc -w -p ./src/addons/webLinks\" \"tsc -w -p ./src/addons/winptyCompat\" \"tsc -w -p ./src/addons/zmodem\" \"gulp watch-css\"" } } diff --git a/src/addons/attach/tsconfig.json b/src/addons/attach/tsconfig.json index 19954249..12e75810 100644 --- a/src/addons/attach/tsconfig.json +++ b/src/addons/attach/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/attach/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/fit/tsconfig.json b/src/addons/fit/tsconfig.json index e1dce37f..f806af18 100644 --- a/src/addons/fit/tsconfig.json +++ b/src/addons/fit/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/fit/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/fullscreen/tsconfig.json b/src/addons/fullscreen/tsconfig.json index 5a06c490..2fbb295f 100644 --- a/src/addons/fullscreen/tsconfig.json +++ b/src/addons/fullscreen/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/fullscreen/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/search/tsconfig.json b/src/addons/search/tsconfig.json index d833bb28..47876a00 100644 --- a/src/addons/search/tsconfig.json +++ b/src/addons/search/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/search/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/terminado/tsconfig.json b/src/addons/terminado/tsconfig.json index 2c795b99..b664a5e0 100644 --- a/src/addons/terminado/tsconfig.json +++ b/src/addons/terminado/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/terminado/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/webLinks/tsconfig.json b/src/addons/webLinks/tsconfig.json index b34f544d..7dd999f6 100644 --- a/src/addons/webLinks/tsconfig.json +++ b/src/addons/webLinks/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/webLinks/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/winptyCompat/tsconfig.json b/src/addons/winptyCompat/tsconfig.json index fdca3e3d..ecad2563 100644 --- a/src/addons/winptyCompat/tsconfig.json +++ b/src/addons/winptyCompat/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/winptyCompat/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/src/addons/zmodem/tsconfig.json b/src/addons/zmodem/tsconfig.json index f5693801..d4577108 100644 --- a/src/addons/zmodem/tsconfig.json +++ b/src/addons/zmodem/tsconfig.json @@ -6,7 +6,8 @@ "outDir": "../../../lib/addons/zmodem/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true }, "include": [ "**/*.ts", diff --git a/tsconfig.json b/tsconfig.json index c33793f5..e39ea642 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,7 @@ "outDir": "lib", "sourceMap": true, "removeComments": true, + "preserveWatchOutput": true, "noUnusedLocals": true, "noImplicitAny": true },