microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
db80cd4e10b83524bc77c15018effab72cbabeb8

Branches

Tags

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

Clone

HTTPS

Download ZIP

gulpfile.js

104lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4var child_process = require('child_process');
5var gulp = require('gulp');
6var log = require('gulp-util').log;
7var sourcemaps = require('gulp-sourcemaps');
8var os = require('os');
9var path = require('path');
10var runSequence = require("run-sequence");
11var ts = require('gulp-typescript');
12var mocha = require('gulp-mocha');
13
14var srcPath = 'src';
15var outPath = 'out';
16
17var sources = [
18 srcPath,
19].map(function (tsFolder) { return tsFolder + '/**/*.ts'; })
20 .concat(['test/*.ts']);
21
22// TODO: The file property should point to the generated source (this implementation adds an extra folder to the path)
23// We should also make sure that we always generate urls in all the path properties (We shouldn't have \\s. This seems to
24// be an issue on Windows platforms)
25gulp.task('build', ['checkImports'], function () {
26 var tsProject = ts.createProject('tsconfig.json');
27 return tsProject.src()
28 .pipe(sourcemaps.init())
29 .pipe(ts(tsProject))
30 .pipe(sourcemaps.write('.', {
31 includeContent: false,
32 sourceRoot: function (file) {
33 return path.relative(path.dirname(file.path), __dirname + '/src');
34 }
35 }))
36 .pipe(gulp.dest(outPath));
37});
38
39gulp.task('watch', ['build'], function (cb) {
40 log('Watching build sources...');
41 return gulp.watch(sources, ['build']);
42});
43
44gulp.task('default', function (callback) {
45 runSequence("clean", "build", "tslint", callback);
46});
47
48var lintSources = [
49 srcPath,
50].map(function (tsFolder) { return tsFolder + '/**/*.ts'; });
51lintSources = lintSources.concat([
52 '!src/typings/**'
53]);
54
55var tslint = require('gulp-tslint');
56gulp.task('tslint', function () {
57 return gulp.src(lintSources, { base: '.' })
58 .pipe(tslint())
59 .pipe(tslint.report('verbose'));
60});
61
62function test() {
63 return gulp.src(['out/test/**/*.test.js', '!out/test/extension/**'])
64 .pipe(mocha({
65 ui: 'tdd',
66 useColors: true,
67 invert: true,
68 grep: "extensionContext" // Do not run tests intended for the extensionContext
69 }));
70}
71
72gulp.task('build-test', ['build'], test);
73gulp.task('test', test);
74
75gulp.task('checkImports', function (cb) {
76 var checkProcess = child_process.fork(path.join(__dirname, "tools", "checkCasing.js"),
77 {
78 cwd: path.resolve(__dirname, "src"),
79 stdio: "inherit"
80 });
81 checkProcess.on("error", cb);
82 checkProcess.on("exit", function (code, signal) {
83 if (code || signal) {
84 cb(new Error("Mismatches found in import casing"));
85 } else {
86 cb();
87 }
88 });
89});
90
91gulp.task('watch-build-test', ['build', 'build-test'], function () {
92 return gulp.watch(sources, ['build', 'build-test']);
93});
94
95gulp.task("clean", function () {
96 var del = require("del");
97 var pathsToDelete = [
98 outPath,
99 ".vscode-test"
100 ].map(function (folder) {
101 return folder + "/**";
102 });
103 return del(pathsToDelete, { force: true });
104});
105