microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
gulpfile.js
77lines · modecode
| 1 | /*--------------------------------------------------------- |
| 2 | * Copyright (C) Microsoft Corporation. All rights reserved. |
| 3 | *--------------------------------------------------------*/ |
| 4 | |
| 5 | var child_process = require('child_process'); |
| 6 | var gulp = require('gulp'); |
| 7 | var log = require('gulp-util').log; |
| 8 | var mocha = require('gulp-mocha'); |
| 9 | var sourcemaps = require('gulp-sourcemaps'); |
| 10 | var os = require('os'); |
| 11 | var path = require('path'); |
| 12 | var runSequence = require("run-sequence"); |
| 13 | var ts = require('gulp-typescript'); |
| 14 | |
| 15 | var srcPath = 'src'; |
| 16 | var outPath = 'out'; |
| 17 | |
| 18 | var sources = [ |
| 19 | srcPath, |
| 20 | ].map(function(tsFolder) { return tsFolder + '/**/*.ts'; }) |
| 21 | .concat(['test/*.ts']); |
| 22 | |
| 23 | // TODO: The file property should point to the generated source (this implementation adds an extra folder to the path) |
| 24 | // We should also make sure that we always generate urls in all the path properties (We shouldn't have \\s. This seems to |
| 25 | // be an issue on Windows platforms) |
| 26 | gulp.task('build', function() { |
| 27 | var tsProject = ts.createProject('tsconfig.json'); |
| 28 | return tsProject.src() |
| 29 | .pipe(sourcemaps.init()) |
| 30 | .pipe(ts(tsProject)) |
| 31 | .pipe(sourcemaps.write('.', { |
| 32 | includeContent: false, |
| 33 | sourceRoot: function(file) { |
| 34 | return path.relative(path.dirname(file.path), __dirname + '/src'); |
| 35 | } |
| 36 | })) |
| 37 | .pipe(gulp.dest(outPath)); |
| 38 | }); |
| 39 | |
| 40 | gulp.task('watch', ['build'], function(cb) { |
| 41 | log('Watching build sources...'); |
| 42 | return gulp.watch(sources, ['build']); |
| 43 | }); |
| 44 | |
| 45 | gulp.task('default', function(callback) { |
| 46 | runSequence("clean", "build", "tslint", callback); |
| 47 | }); |
| 48 | |
| 49 | var lintSources = [ |
| 50 | srcPath, |
| 51 | ].map(function(tsFolder) { return tsFolder + '/**/*.ts'; }); |
| 52 | lintSources = lintSources.concat([ |
| 53 | '!src/typings/**' |
| 54 | ]); |
| 55 | |
| 56 | var tslint = require('gulp-tslint'); |
| 57 | gulp.task('tslint', function() { |
| 58 | return gulp.src(lintSources, { base: '.' }) |
| 59 | .pipe(tslint()) |
| 60 | .pipe(tslint.report('verbose')); |
| 61 | }); |
| 62 | |
| 63 | function test() { |
| 64 | throw new Error('No tests yet'); |
| 65 | } |
| 66 | |
| 67 | gulp.task('build-test', ['build'], test); |
| 68 | gulp.task('test', test); |
| 69 | |
| 70 | gulp.task('watch-build-test', ['build', 'build-test'], function() { |
| 71 | return gulp.watch(sources, ['build', 'build-test']); |
| 72 | }); |
| 73 | |
| 74 | gulp.task("clean", function() { |
| 75 | var del = require("del"); |
| 76 | return del([outPath + "/**"], { force: true }); |
| 77 | }); |