vsts-vmware/gulpfile.js

96 строки
3.1 KiB
JavaScript
Исходник Обычный вид История

2015-12-02 15:16:46 +03:00
var gulp = require("gulp");
var rimraf = require("rimraf");
var tsb = require("gulp-tsb");
var mocha = require("gulp-mocha");
var tslint = require("gulp-tslint");
var istanbul = require("gulp-istanbul");
var path = require("path");
var shell = require('shelljs')
var gutil = require('gulp-util');
2015-12-02 15:16:46 +03:00
var buildDirectory = "_build";
2015-12-21 19:05:34 +03:00
var packageDirectory = "_package";
var sourcePaths = {
typescriptFiles: "src/**/*.ts",
copyFiles: ["src/*.json", "src/*.md", "src/Images/*", "src/Tasks/**/*.json", "src/Tasks/**/*.js", "src/Tasks/**/*.md", "src/Tasks/**/*.png", "src/Tasks/**/*.svg"]
};
var testPaths = {
typescriptFiles: "tests/**/*.ts",
copyfiles: ["tests/**/*.js"],
compiledJSFiles: buildDirectory + "/**/*Tests*.js"
};
2015-12-21 19:05:34 +03:00
var manifestFile = "vss-extension.json";
var jsCoverageDir = path.join(buildDirectory, "codecoverage");
2015-12-02 15:16:46 +03:00
// create and keep compiler
var compilation = tsb.create({
target: 'es5',
module: 'commonjs',
declaration: false,
verbose: false
2015-12-02 15:16:46 +03:00
});
gulp.task("compile", ["lint"], function() {
return gulp.src([sourcePaths.typescriptFiles, testPaths.typescriptFiles], { base: "." })
2015-12-02 15:16:46 +03:00
.pipe(compilation())
.pipe(gulp.dest(__dirname))
.pipe(istanbul({includeUntested: true}))
.pipe(istanbul.hookRequire());
2015-12-02 15:16:46 +03:00
});
gulp.task("build", ["compile"], function() {
var copyFiles = sourcePaths.copyFiles.concat(testPaths.copyfiles);
return gulp.src(copyFiles, { base: "." })
.pipe(gulp.dest(buildDirectory));
});
gulp.task("lint", function() {
return gulp.src([sourcePaths.typescriptFiles, testPaths.typescriptFiles])
2015-12-02 15:16:46 +03:00
.pipe(tslint())
.pipe(tslint.report("verbose"))
});
gulp.task("clean", function(done) {
return rimraf(buildDirectory, function() {
// rimraf deletes the directory asynchronously
done();
});
});
gulp.task("test", ["build"], function() {
return gulp.src(testPaths.compiledJSFiles, { read: false })
.pipe(mocha())
.pipe(istanbul.writeReports({
dir: jsCoverageDir,
reportOpts: { dir: jsCoverageDir }
}))
.pipe(istanbul.enforceThresholds({ thresholds: { global: 95 } }));
});
gulp.task("testci", ["build"], function() {
return gulp.src(testPaths.compiledJSFiles, { read: false })
.pipe(mocha({ reporter: "xunit", reporterOptions: { output: path.join(buildDirectory, "mochaTestResult.xml") } }))
.pipe(istanbul.writeReports({
dir: jsCoverageDir,
reportOpts: { dir: jsCoverageDir }
}))
.pipe(istanbul.enforceThresholds({ thresholds: { global: 95 } }));
});
2015-12-21 19:05:34 +03:00
gulp.task("package", ["build"], function() {
var srcBuildDirectory = buildDirectory + "/src";
if(shell.exec("tfx extension create --manifest-globs " + manifestFile + " --root " + srcBuildDirectory + " --output-path " + packageDirectory).code !== 0) {
throw new gutil.PluginError({
plugin: "package",
message: "Unable to create package."
});
}
});
gulp.task("watch", function() {
gulp.watch([sourcePaths.typescriptFiles, testPaths.typescriptFiles], ["test"]);
2015-12-02 15:16:46 +03:00
});
gulp.task("default", ["build"]);