This commit is contained in:
Leo Lee (DEVDIV) 2015-02-02 19:32:19 -08:00
Родитель 6094ebfa0b
Коммит 42ea89e357
2 изменённых файлов: 17 добавлений и 42 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -1,20 +1,20 @@
/// <reference path="typings/node.d.ts" />
/// <reference path="typings/q.d.ts" />
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;