diff --git a/src/gulpfile.js b/src/gulpfile.js index 6e01cde0..9580d9ed 100644 --- a/src/gulpfile.js +++ b/src/gulpfile.js @@ -25,10 +25,7 @@ gulp.task("install", function (callback) { var gulpMain = "../bin/src/gulpmain.js"; if (fs.existsSync(gulpMain)) { - console.log("found"); require(gulpMain); } -else { - console.log("not found: " + path.resolve(gulpMain)); -} + module.exports = gulp; diff --git a/src/gulpmain.ts b/src/gulpmain.ts index af149b38..1dce1523 100644 --- a/src/gulpmain.ts +++ b/src/gulpmain.ts @@ -1,20 +1,20 @@ /// /// + var fs = require("fs"); var gulp = require("gulp"); +var del = require("del"); var path = require("path"); var exec = require("child_process").exec; import stylecopUtil = require("../tools/stylecop-util"); import tsUtil = require("./taco-cli/compile/typescript-util"); import dtsUtil = require("../tools/tsdefinition-util"); -var del = require("del"); -var ncp = require("ncp"); -var Q = require("q"); var compilerPath = { src: ".", // gulp task compiles all source under "taco-cli" source folder - bin: "../bin", + bin: "../bin/src", + tools: "../bin/tools" }; var copFile = path.join(compilerPath.src, "../tools/internal/TSStyleCop.js"); @@ -27,17 +27,16 @@ gulp.task("default", ["rebuild"]); /* Compiles the typescript files in the project, for fast iterative use */ gulp.task("compile", function (callback: Function): void { - compileTS(callback); + var tsCompiler = new tsUtil.TypeScriptServices(); + console.log("compilerPath.src: " + path.resolve(compilerPath.src)); + console.log("compilerPath.bin: " + path.resolve(compilerPath.bin)); + tsCompiler.compileDirectory(compilerPath.src, compilerPath.bin, callback); }); /* full clean build */ -gulp.task("rebuild", ["copy-package-json", "run-stylecop", "copy-resources"], function (callback: Function): void { - compileTS(callback); -}); - -/* full clean build */ -gulp.task("clean-build", ["clean"], function (callback: Function): void { - compileTS(callback); +gulp.task("rebuild", ["clean"], function (callback: Function): void { + gulp.run("compile"); + gulp.run("copy"); }); /* Runs style cop on the sources. */ @@ -50,29 +49,15 @@ gulp.task("run-stylecop", ["clean-build"], function (callback: Function): void { } }); -/* Cleans up the bin location. */ +/* Cleans up the bin location, will have to call "gulp prep" again */ gulp.task("clean", function (callback: Function): void { - //del([compilerPath.bin + "/**"], { force: true }, callback); - console.log("abc"); + del([compilerPath.bin + "/../**"], { force: true }, callback); }); /* copy package.json files from source to bin */ -gulp.task("copy-package-json", ["clean-build"], function (callback: Function): void { - var cliPath: string = "/taco-cli/package.json"; - var utilPath: string = "/taco-utils/package.json"; - fs.writeFileSync(path.join(compilerPath.bin, cliPath), fs.readFileSync(path.join(compilerPath.src, cliPath))); - fs.writeFileSync(path.join(compilerPath.bin, utilPath), fs.readFileSync(path.join(compilerPath.src, utilPath))); - callback(); -}); - -/* copy package.json files from source to bin */ -gulp.task("copy-resources", ["clean-build"], function (callback: Function): void { - ncp(path.join(compilerPath.src, "taco-cli/resources"), path.join(compilerPath.bin, "taco-cli/resources"), {clobber: true}, callback) -}); - -/* with package.json files setup in Bin folder, call npm install */ -gulp.task("install-bin-modules", ["copy-package-json"], function (callback: Function): void { - exec("npm install", { cwd: path.join(compilerPath.bin, "taco-cli")}, callback); +gulp.task("copy", function (callback: Function): void { + gulp.src(path.join(compilerPath.src, "/**/package.json")).pipe(gulp.dest(compilerPath.bin)); + gulp.src(path.join(compilerPath.src, "/**/resources.json")).pipe(gulp.dest(compilerPath.bin)); }); /* auto-generate taco-utils.d.ts*/ @@ -87,14 +72,7 @@ gulp.task("generate-dts", function (cb: Function): void { cb(); }); -function compileTS(callback: Function) { - var tsCompiler = new tsUtil.TypeScriptServices(); - console.log("compilerPath.src: " + path.resolve(compilerPath.src)); - console.log("compilerPath.bin: " + path.resolve(compilerPath.bin)); - tsCompiler.compileDirectory(compilerPath.src, compilerPath.bin, callback); -} /* Task to generate NPM package */ /* Task to run tests */ - module.exports = gulp;