microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
tools/compileTools.js
40lines · 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 | |
| 4 | var buildConfig = require('./tsconfig.json'); |
| 5 | var path = require("path"); |
| 6 | |
| 7 | function compileBuildScripts() { |
| 8 | console.log("Compiling tools...\n"); |
| 9 | var gulp = require("gulp"); |
| 10 | var ts = require('gulp-typescript'); |
| 11 | var sourcemaps = require("gulp-sourcemaps"); |
| 12 | gulp.src(["src/**/*.ts"]) |
| 13 | .pipe(sourcemaps.init()) |
| 14 | .pipe(ts(buildConfig.tsCompileOptions)) |
| 15 | .on("error", function(error){ |
| 16 | if (error) { |
| 17 | console.error("Failed: Compilation of tools failed."); |
| 18 | process.exit(1); |
| 19 | } |
| 20 | }) |
| 21 | .pipe(sourcemaps.write(".")) |
| 22 | .pipe(gulp.dest(path.resolve("out"))) |
| 23 | .on("end", function(){ |
| 24 | console.log(greenColorFunction("Success!!! To build the project, run 'gulp' from the root directory")); |
| 25 | }); |
| 26 | } |
| 27 | |
| 28 | function greenColorFunction(s) { |
| 29 | // https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes |
| 30 | // \u001b[3Xm == "set foreground colour to colour in slot X" |
| 31 | // Slot 2 defaults to green |
| 32 | // \u001b[39m == "reset foreground colour" |
| 33 | // \u001b[1m == "bold" which is interpreted differently by different terminals |
| 34 | // \u001b[22m == "stop being bold (or faint)" |
| 35 | return "\u001b[32m\u001b[1m" + s + "\u001b[22m\u001b[39m"; |
| 36 | } |
| 37 | |
| 38 | process.chdir("tools"); // Go to the tools folder |
| 39 | |
| 40 | compileBuildScripts(); |