microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
18d8ad2abfdce9bcdb96cc3fe6fb491da873c8f6

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

gulpfile.js

134lines · modeblame

b8ecee4ddigeff10 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
8ba55f4cJimmy Thomson10 years ago3
4var gulp = require('gulp');
3fb37ad5unknown10 years ago5var log = require('gulp-util').log;
8ba55f4cJimmy Thomson10 years ago6var sourcemaps = require('gulp-sourcemaps');
7var path = require('path');
3fb37ad5unknown10 years ago8var runSequence = require("run-sequence");
9var ts = require('gulp-typescript');
d500558fJimmy Thomson10 years ago10var mocha = require('gulp-mocha');
9adec70dJoshua Skelton10 years ago11var GulpExtras = require("./tools/gulp-extras");
12var copyright = GulpExtras.checkCopyright;
13var imports = GulpExtras.checkImports;
7212311dDaniel Lebu10 years ago14var executeCommand = GulpExtras.executeCommand;
8ba55f4cJimmy Thomson10 years ago15
89973b41dlebu10 years ago16var srcPath = 'src';
17var outPath = 'out';
18
8ba55f4cJimmy Thomson10 years ago19var sources = [
89973b41dlebu10 years ago20srcPath,
ee16550eGuillaume Jenkins10 years ago21].map(function (tsFolder) { return tsFolder + '/**/*.ts'; })
3fb37ad5unknown10 years ago22.concat(['test/*.ts']);
8ba55f4cJimmy Thomson10 years ago23
c55d31ecdigeff10 years ago24// TODO: The file property should point to the generated source (this implementation adds an extra folder to the path)
25// We should also make sure that we always generate urls in all the path properties (We shouldn't have \\s. This seems to
26// be an issue on Windows platforms)
9425034eJoshua Skelton10 years ago27gulp.task('build', ["check-imports", "check-copyright"], function () {
c55d31ecdigeff10 years ago28var tsProject = ts.createProject('tsconfig.json');
8ba55f4cJimmy Thomson10 years ago29return tsProject.src()
30.pipe(sourcemaps.init())
31.pipe(ts(tsProject))
c55d31ecdigeff10 years ago32.pipe(sourcemaps.write('.', {
33includeContent: false,
ee16550eGuillaume Jenkins10 years ago34sourceRoot: function (file) {
c55d31ecdigeff10 years ago35return path.relative(path.dirname(file.path), __dirname + '/src');
36}
37}))
89973b41dlebu10 years ago38.pipe(gulp.dest(outPath));
8ba55f4cJimmy Thomson10 years ago39});
40
ee16550eGuillaume Jenkins10 years ago41gulp.task('watch', ['build'], function (cb) {
8ba55f4cJimmy Thomson10 years ago42log('Watching build sources...');
43return gulp.watch(sources, ['build']);
44});
45
ee16550eGuillaume Jenkins10 years ago46gulp.task('default', function (callback) {
89973b41dlebu10 years ago47runSequence("clean", "build", "tslint", callback);
3fb37ad5unknown10 years ago48});
8ba55f4cJimmy Thomson10 years ago49
50var lintSources = [
89973b41dlebu10 years ago51srcPath,
ee16550eGuillaume Jenkins10 years ago52].map(function (tsFolder) { return tsFolder + '/**/*.ts'; });
3fde2079Jimmy Thomson10 years ago53lintSources = lintSources.concat([
54'!src/typings/**'
55]);
8ba55f4cJimmy Thomson10 years ago56
57var tslint = require('gulp-tslint');
ee16550eGuillaume Jenkins10 years ago58gulp.task('tslint', function () {
3fb37ad5unknown10 years ago59return gulp.src(lintSources, { base: '.' })
8ba55f4cJimmy Thomson10 years ago60.pipe(tslint())
61.pipe(tslint.report('verbose'));
62});
63
e8979052digeff10 years ago64function readArgument(argumentName) {
c4394a1ddigeff10 years ago65var argumentNameIndex = process.argv.indexOf("--" + argumentName);
66var argumentValueIndex = argumentNameIndex + 1;
67return argumentNameIndex > -1 && argumentValueIndex < process.argv.length
68? process.argv[argumentValueIndex]
e8979052digeff10 years ago69: null;
70}
71
8ba55f4cJimmy Thomson10 years ago72function test() {
211ffe84digeff10 years ago73// Defaults
74var invert = true;
75
76// Check if arguments were passed
e8979052digeff10 years ago77var pattern = readArgument("pattern");
78if (pattern !== null) {
211ffe84digeff10 years ago79invert = false;
80console.log("\nTesting cases that match pattern: " + pattern);
7d22ec66digeff10 years ago81} else {
82pattern = "extensionContext";
db7fa079digeff10 years ago83console.log("\nTesting cases that don't match pattern: " + pattern);
211ffe84digeff10 years ago84}
85
d500558fJimmy Thomson10 years ago86return gulp.src(['out/test/**/*.test.js', '!out/test/extension/**'])
87.pipe(mocha({
88ui: 'tdd',
89useColors: true,
211ffe84digeff10 years ago90invert: invert,
91grep: pattern
d500558fJimmy Thomson10 years ago92}));
8ba55f4cJimmy Thomson10 years ago93}
94
95gulp.task('build-test', ['build'], test);
96gulp.task('test', test);
97
9425034eJoshua Skelton10 years ago98gulp.task('check-imports', function (cb) {
9adec70dJoshua Skelton10 years ago99var tsProject = ts.createProject('tsconfig.json');
100return tsProject.src()
101.pipe(imports());
7d0d8776digeff10 years ago102});
103
9425034eJoshua Skelton10 years ago104gulp.task('check-copyright', function (cb) {
a3fd5ee9Joshua Skelton10 years ago105return gulp.src([
106"**/*.ts",
107"**/*.js",
108"!**/*.d.ts",
109"!node_modules/**/*.*",
110"!SampleApplication/**/*.js"
111])
9adec70dJoshua Skelton10 years ago112.pipe(copyright());
7d0d8776digeff10 years ago113});
379834c9Jimmy Thomson10 years ago114
ee16550eGuillaume Jenkins10 years ago115gulp.task('watch-build-test', ['build', 'build-test'], function () {
8ba55f4cJimmy Thomson10 years ago116return gulp.watch(sources, ['build', 'build-test']);
117});
89973b41dlebu10 years ago118
ee16550eGuillaume Jenkins10 years ago119gulp.task("clean", function () {
89973b41dlebu10 years ago120var del = require("del");
ee16550eGuillaume Jenkins10 years ago121var pathsToDelete = [
122outPath,
123".vscode-test"
124].map(function (folder) {
125return folder + "/**";
126});
127return del(pathsToDelete, { force: true });
8edb50b4Jimmy Thomson10 years ago128});
7212311dDaniel Lebu10 years ago129
130gulp.task("package", function (callback) {
3ab5abaaDaniel Lebu10 years ago131var command = path.join(__dirname, "node_modules", ".bin", "vsce" + (process.platform === "win32" ? ".cmd" : ""));
7212311dDaniel Lebu10 years ago132var args = ["package"];
133executeCommand(command, args, callback);
134});