Closed sudiptosen closed 6 years ago
gulp.src(paths.srcAll)
will load all TypeScript files in your project, including lib (.d.ts
) files from node_modules/typescript
. Could you try to replace that with gulp.src(paths.src)
or tsProject1.src()
?
Yes, you are right 👍 Thank you so much.
'tsProject1.src()' worked perfectly for me.
Cleaned up gulpfile and posting, might help someone.
gulpfile.js
let gulp = require("gulp");
let watch = require("gulp-watch");
let gulpts = require("gulp-typescript");
let jasmine = require("gulp-jasmine");
let gulputil = require("gulp-util");
let clean = require("gulp-clean");
let paths={
src: "./src/**/*.ts",
spec: "./spec/**/*.ts",
specJs: "./output/**/*[Ss]pec.js",
output: "./output"
};
gulp.task('default', ['build']);
let buildCounter = 0;
gulp.task('build', ['cleanup'], ()=>{
let target = [].concat(paths.src, paths.spec);
runJasmine();
gulputil.log("Watching for changes....");
return watch(target, ()=>{
gulputil.log("Starting build...");
let tsProject = gulpts.createProject("tsconfig.json");
tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest(paths.output))
.on('end', postBuild)
})
});
process.on('uncaughtException', (err)=>{
console.log("Error detected.");
console.log(err);
});
gulp.task('cleanup', ()=>{
gulp.src(paths.output)
.pipe(clean());
});
function postBuild(){
gulputil.log("------------------------------------------------------");
gulputil.log("**** Finished Build# " + (++buildCounter) + " ****") ;
gulputil.log("------------------------------------------------------");
runJasmine();
}
function runJasmine(){
// ==================================================================
// Jasmine console reporter setup
// ==================================================================
const JasmineConsoleReporter = require('jasmine-console-reporter');
const consoleReporter = new JasmineConsoleReporter({
colors: 1, // (0|false)|(1|true)|2
cleanStack: 1, // (0|false)|(1|true)|2|3
verbosity: 4, // (0|false)|1|2|(3|true)|4
listStyle: 'indent', // "flat"|"indent"
activity: false
});
// ==================================================================
gulp.src(paths.specJs)
.pipe(jasmine({
reporter: consoleReporter
}))
.on('end', ()=> gulputil.log("Watching for changes...."));
}
Thanks.
Hi,
I have a very simple
tsconfig
: Only intent is to outputsrc
andspec
separately to an output folder. Then, I want to simply pipe(jasmine()) after every pipe(tsproject()) on a gulp-watchExpected behavior:
Given my project structure /myproject -/src -/spec -tsconfig.json -gulpfile.js
Given following environment Node: 8.9.4 TSC: 2.7.2
Give the devDependencies
After running either
tsc
or using gulp-typescript the output should be: /output -/src -/specActual behavior:
tsc
runs and outputs as expected. I can run jasmine and all good.When the gulp-typescript runs, I get a ton of these
gulpfile.js
tsconfig.json