microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
30d12ab8ec0f57ab20a3dc05bbb13707e040d75e

Branches

Tags

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

Clone

HTTPS

Download ZIP

gulpfile.js

108lines · 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');
13var GulpExtras = require("./tools/gulp-extras");
14var copyright = GulpExtras.checkCopyright;
15var imports = GulpExtras.checkImports;
16
17var srcPath = 'src';
18var outPath = 'out';
19
20var sources = [
21 srcPath,
22].map(function (tsFolder) { return tsFolder + '/**/*.ts'; })
23 .concat(['test/*.ts']);
24
25// TODO: The file property should point to the generated source (this implementation adds an extra folder to the path)
26// We should also make sure that we always generate urls in all the path properties (We shouldn't have \\s. This seems to
27// be an issue on Windows platforms)
28gulp.task('build', ["check-imports", "check-copyright"], function () {
29 var tsProject = ts.createProject('tsconfig.json');
30 return tsProject.src()
31 .pipe(sourcemaps.init())
32 .pipe(ts(tsProject))
33 .pipe(sourcemaps.write('.', {
34 includeContent: false,
35 sourceRoot: function (file) {
36 return path.relative(path.dirname(file.path), __dirname + '/src');
37 }
38 }))
39 .pipe(gulp.dest(outPath));
40});
41
42gulp.task('watch', ['build'], function (cb) {
43 log('Watching build sources...');
44 return gulp.watch(sources, ['build']);
45});
46
47gulp.task('default', function (callback) {
48 runSequence("clean", "build", "tslint", callback);
49});
50
51var lintSources = [
52 srcPath,
53].map(function (tsFolder) { return tsFolder + '/**/*.ts'; });
54lintSources = lintSources.concat([
55 '!src/typings/**'
56]);
57
58var tslint = require('gulp-tslint');
59gulp.task('tslint', function () {
60 return gulp.src(lintSources, { base: '.' })
61 .pipe(tslint())
62 .pipe(tslint.report('verbose'));
63});
64
65function test() {
66 return gulp.src(['out/test/**/*.test.js', '!out/test/extension/**'])
67 .pipe(mocha({
68 ui: 'tdd',
69 useColors: true,
70 invert: true,
71 grep: "extensionContext" // Do not run tests intended for the extensionContext
72 }));
73}
74
75gulp.task('build-test', ['build'], test);
76gulp.task('test', test);
77
78gulp.task('check-imports', function (cb) {
79 var tsProject = ts.createProject('tsconfig.json');
80 return tsProject.src()
81 .pipe(imports());
82});
83
84gulp.task('check-copyright', function (cb) {
85 return gulp.src([
86 "**/*.ts",
87 "**/*.js",
88 "!**/*.d.ts",
89 "!node_modules/**/*.*",
90 "!SampleApplication/**/*.js"
91 ])
92 .pipe(copyright());
93});
94
95gulp.task('watch-build-test', ['build', 'build-test'], function () {
96 return gulp.watch(sources, ['build', 'build-test']);
97});
98
99gulp.task("clean", function () {
100 var del = require("del");
101 var pathsToDelete = [
102 outPath,
103 ".vscode-test"
104 ].map(function (folder) {
105 return folder + "/**";
106 });
107 return del(pathsToDelete, { force: true });
108});
109