microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.1.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

gulpfile.js

112lines · 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 child_process = require('child_process');
5var gulp = require('gulp');
3fb37ad5unknown10 years ago6var log = require('gulp-util').log;
8ba55f4cJimmy Thomson10 years ago7var sourcemaps = require('gulp-sourcemaps');
8var os = require('os');
9var path = require('path');
3fb37ad5unknown10 years ago10var runSequence = require("run-sequence");
11var ts = require('gulp-typescript');
d500558fJimmy Thomson10 years ago12var mocha = require('gulp-mocha');
8ba55f4cJimmy Thomson10 years ago13
89973b41dlebu10 years ago14var srcPath = 'src';
15var outPath = 'out';
16
8ba55f4cJimmy Thomson10 years ago17var sources = [
89973b41dlebu10 years ago18srcPath,
ee16550eGuillaume Jenkins10 years ago19].map(function (tsFolder) { return tsFolder + '/**/*.ts'; })
3fb37ad5unknown10 years ago20.concat(['test/*.ts']);
8ba55f4cJimmy Thomson10 years ago21
c55d31ecdigeff10 years ago22// 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)
9508f4d8digeff10 years ago25gulp.task('build', ['checkImports', 'checkCopyright'], function () {
c55d31ecdigeff10 years ago26var tsProject = ts.createProject('tsconfig.json');
8ba55f4cJimmy Thomson10 years ago27return tsProject.src()
28.pipe(sourcemaps.init())
29.pipe(ts(tsProject))
c55d31ecdigeff10 years ago30.pipe(sourcemaps.write('.', {
31includeContent: false,
ee16550eGuillaume Jenkins10 years ago32sourceRoot: function (file) {
c55d31ecdigeff10 years ago33return path.relative(path.dirname(file.path), __dirname + '/src');
34}
35}))
89973b41dlebu10 years ago36.pipe(gulp.dest(outPath));
8ba55f4cJimmy Thomson10 years ago37});
38
ee16550eGuillaume Jenkins10 years ago39gulp.task('watch', ['build'], function (cb) {
8ba55f4cJimmy Thomson10 years ago40log('Watching build sources...');
41return gulp.watch(sources, ['build']);
42});
43
ee16550eGuillaume Jenkins10 years ago44gulp.task('default', function (callback) {
89973b41dlebu10 years ago45runSequence("clean", "build", "tslint", callback);
3fb37ad5unknown10 years ago46});
8ba55f4cJimmy Thomson10 years ago47
48var lintSources = [
89973b41dlebu10 years ago49srcPath,
ee16550eGuillaume Jenkins10 years ago50].map(function (tsFolder) { return tsFolder + '/**/*.ts'; });
3fde2079Jimmy Thomson10 years ago51lintSources = lintSources.concat([
52'!src/typings/**'
53]);
8ba55f4cJimmy Thomson10 years ago54
55var tslint = require('gulp-tslint');
ee16550eGuillaume Jenkins10 years ago56gulp.task('tslint', function () {
3fb37ad5unknown10 years ago57return gulp.src(lintSources, { base: '.' })
8ba55f4cJimmy Thomson10 years ago58.pipe(tslint())
59.pipe(tslint.report('verbose'));
60});
61
62function test() {
d500558fJimmy Thomson10 years ago63return gulp.src(['out/test/**/*.test.js', '!out/test/extension/**'])
64.pipe(mocha({
65ui: 'tdd',
66useColors: true,
67invert: true,
68grep: "extensionContext" // Do not run tests intended for the extensionContext
69}));
8ba55f4cJimmy Thomson10 years ago70}
71
72gulp.task('build-test', ['build'], test);
73gulp.task('test', test);
74
7d0d8776digeff10 years ago75function runCustomVerification(pathInTools, errorMessage, cb) {
76var checkProcess = child_process.fork(path.join(__dirname, "tools", pathInTools),
77{
78cwd: path.resolve(__dirname, "src"),
79stdio: "inherit"
379834c9Jimmy Thomson10 years ago80});
7d0d8776digeff10 years ago81checkProcess.on("error", cb);
82checkProcess.on("exit", function (code, signal) {
83if (code || signal) {
84cb(new Error(errorMessage));
85} else {
86cb();
87}
379834c9Jimmy Thomson10 years ago88});
9508f4d8digeff10 years ago89}
90
7d0d8776digeff10 years ago91gulp.task('checkImports', function (cb) {
92runCustomVerification("checkCasing.js", "Mismatches found in import casing", cb);
93});
94
95gulp.task('checkCopyright', function (cb) {
96runCustomVerification("checkCopyright.js", "Some source code files don't have the expected copyright notice", cb);
97});
379834c9Jimmy Thomson10 years ago98
ee16550eGuillaume Jenkins10 years ago99gulp.task('watch-build-test', ['build', 'build-test'], function () {
8ba55f4cJimmy Thomson10 years ago100return gulp.watch(sources, ['build', 'build-test']);
101});
89973b41dlebu10 years ago102
ee16550eGuillaume Jenkins10 years ago103gulp.task("clean", function () {
89973b41dlebu10 years ago104var del = require("del");
ee16550eGuillaume Jenkins10 years ago105var pathsToDelete = [
106outPath,
107".vscode-test"
108].map(function (folder) {
109return folder + "/**";
110});
111return del(pathsToDelete, { force: true });
8edb50b4Jimmy Thomson10 years ago112});