提交 1ef9a66d 编写于 作者: J Joao Moreno

Revert "revert changes to gulp files"

This reverts commit 23afe969.
上级 43c6e13a
{
"env": {
"node": true
"node": true,
"es6": true
},
"rules": {
"no-undef": 2,
"no-unused-vars": 1
}
"no-console": 0
},
"extends": "eslint:recommended"
}
\ No newline at end of file
......@@ -25,14 +25,14 @@
"absolute"
],
"pattern": {
"regexp": "^\\*\\*\\* Error: ([^(]+)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\): (.*)$",
"regexp": "Error: ([^(]+)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\): (.*)$",
"file": 1,
"location": 2,
"message": 3
},
"watching": {
"beginsPattern": "^\\*\\*\\* Starting\\.\\.\\.$",
"endsPattern": "^\\*\\*\\* Finished"
"beginsPattern": "Starting compilation",
"endsPattern": "Finished compilation"
}
}
},
......
......@@ -17,8 +17,6 @@ var util = require('./lib/util');
var i18n = require('./lib/i18n');
var gulpUtil = require('gulp-util');
var quiet = !!process.env['VSCODE_BUILD_QUIET'];
function log(prefix, message) {
gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message);
}
......@@ -26,16 +24,6 @@ function log(prefix, message) {
var root = path.dirname(__dirname);
var commit = util.getVersion(root);
var tsOptions = {
target: 'ES5',
module: 'amd',
verbose: !quiet,
preserveConstEnums: true,
experimentalDecorators: true,
sourceMap: true,
rootDir: path.join(path.dirname(__dirname), 'src')
};
exports.loaderConfig = function (emptyPaths) {
var result = {
paths: {
......@@ -75,7 +63,7 @@ function loader(bundledFileHeader) {
.pipe(util.loadSourcemaps())
.pipe(concat('vs/loader.js'))
.pipe(es.mapSync(function (f) {
f.sourceMap.sourceRoot = util.toFileUri(tsOptions.rootDir);
f.sourceMap.sourceRoot = util.toFileUri(path.join(path.dirname(__dirname), 'src'));
return f;
}));
}
......
......@@ -19,7 +19,6 @@ var glob = require('glob');
var sourcemaps = require('gulp-sourcemaps');
var nlsDev = require('vscode-nls-dev');
var quiet = !!process.env['VSCODE_BUILD_QUIET'];
var extensionsPath = path.join(path.dirname(__dirname), 'extensions');
var compilations = glob.sync('**/tsconfig.json', {
......@@ -34,7 +33,7 @@ var tasks = compilations.map(function(tsconfigFile) {
var relativeDirname = path.dirname(tsconfigFile);
var tsOptions = require(absolutePath).compilerOptions;
tsOptions.verbose = !quiet;
tsOptions.verbose = false;
tsOptions.sourceMap = true;
var name = relativeDirname.replace(/\//g, '-');
......@@ -56,15 +55,15 @@ var tasks = compilations.map(function(tsconfigFile) {
var i18n = path.join(__dirname, '..', 'i18n');
function createPipeline(build) {
var reporter = quiet ? null : createReporter();
var reporter = createReporter();
tsOptions.inlineSources = !!build;
var compilation = tsb.create(tsOptions, null, null, quiet ? null : function (err) { reporter(err.toString()); });
var compilation = tsb.create(tsOptions, null, null, err => reporter(err.toString()));
return function () {
var input = es.through();
var tsFilter = filter(['**/*.ts', '!**/lib/lib*.d.ts', '!**/node_modules/**'], { restore: true });
var output = input
const input = es.through();
const tsFilter = filter(['**/*.ts', '!**/lib/lib*.d.ts', '!**/node_modules/**'], { restore: true });
const output = input
.pipe(tsFilter)
.pipe(util.loadSourcemaps())
.pipe(compilation())
......@@ -73,27 +72,27 @@ var tasks = compilations.map(function(tsconfigFile) {
addComment: false,
includeContent: !!build,
sourceRoot: function(file) {
var levels = file.relative.split(path.sep).length;
const levels = file.relative.split(path.sep).length;
return '../'.repeat(levels) + 'src';
}
}))
.pipe(tsFilter.restore)
.pipe(build ? nlsDev.createAdditionalLanguageFiles(languages, i18n, out) : es.through())
.pipe(quiet ? es.through() : reporter.end());
.pipe(reporter.end());
return es.duplex(input, output);
};
};
}
var srcOpts = { cwd: path.dirname(__dirname), base: srcBase };
const srcOpts = { cwd: path.dirname(__dirname), base: srcBase };
gulp.task(clean, function (cb) {
rimraf(out, cb);
});
gulp.task(compile, [clean], function () {
var pipeline = createPipeline(false);
var input = gulp.src(src, srcOpts);
const pipeline = createPipeline(false);
const input = gulp.src(src, srcOpts);
return input
.pipe(pipeline())
......@@ -101,9 +100,9 @@ var tasks = compilations.map(function(tsconfigFile) {
});
gulp.task(watch, [clean], function () {
var pipeline = createPipeline(false);
var input = gulp.src(src, srcOpts);
var watchInput = watcher(src, srcOpts);
const pipeline = createPipeline(false);
const input = gulp.src(src, srcOpts);
const watchInput = watcher(src, srcOpts);
return watchInput
.pipe(util.incremental(pipeline, input))
......@@ -115,8 +114,8 @@ var tasks = compilations.map(function(tsconfigFile) {
});
gulp.task(compileBuild, [clean], function () {
var pipeline = createPipeline(true);
var input = gulp.src(src, srcOpts);
const pipeline = createPipeline(true);
const input = gulp.src(src, srcOpts);
return input
.pipe(pipeline())
......@@ -124,8 +123,9 @@ var tasks = compilations.map(function(tsconfigFile) {
});
gulp.task(watchBuild, [clean], function () {
var input = gulp.src(src, srcOpts);
var watchInput = watcher(src, srcOpts);
const pipeline = createPipeline(true);
const input = gulp.src(src, srcOpts);
const watchInput = watcher(src, srcOpts);
return watchInput
.pipe(util.incremental(function () { return pipeline(true); }, input))
......
此差异已折叠。
......@@ -11,13 +11,8 @@ import { ThroughStream } from 'through';
import File = require('vinyl');
import * as Is from 'is';
const quiet = !!process.env['VSCODE_BUILD_QUIET'] && false;
var util = require('gulp-util');
function log(message: any, ...rest: any[]): void {
if (quiet) {
return;
}
util.log(util.colors.cyan('[i18n]'), message, ...rest);
}
......
此差异已折叠。
......@@ -3,18 +3,23 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var es = require('event-stream');
var _ = require('underscore');
'use strict';
var allErrors = [];
var count = 0;
const es = require('event-stream');
const _ = require('underscore');
const util = require('gulp-util');
const allErrors = [];
let startTime = null;
let count = 0;
function onStart() {
if (count++ > 0) {
return;
}
console.log('*** Starting...');
startTime = new Date().getTime();
util.log(util.colors.green('Starting compilation'));
}
function onEnd() {
......@@ -23,8 +28,9 @@ function onEnd() {
}
var errors = _.flatten(allErrors);
errors.map(function (err) { console.error('*** Error:', err); });
console.log('*** Finished with', errors.length, 'errors.');
errors.map(err => util.log(`${ util.colors.red('Error') }: ${ err }`));
util.log(`${ util.colors.green('Finished compilation') } with ${ util.colors.red(errors.length + ' errors') } in ${ util.colors.blue((new Date().getTime() - startTime) + 'ms') }.`);
}
module.exports = function () {
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var ts = require('typescript');
var Lint = require('tslint/lib/lint');
/**
* Implementation of the no-unexternalized-strings rule.
*/
var Rule = (function (_super) {
__extends(Rule, _super);
function Rule() {
_super.apply(this, arguments);
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions()));
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function isStringLiteral(node) {
return node && node.kind === ts.SyntaxKind.StringLiteral;
}
function isObjectLiteral(node) {
return node && node.kind === ts.SyntaxKind.ObjectLiteralExpression;
}
function isPropertyAssignment(node) {
return node && node.kind === ts.SyntaxKind.PropertyAssignment;
}
var NoUnexternalizedStringsRuleWalker = (function (_super) {
__extends(NoUnexternalizedStringsRuleWalker, _super);
function NoUnexternalizedStringsRuleWalker(file, opts) {
var _this = this;
_super.call(this, file, opts);
this.signatures = Object.create(null);
this.ignores = Object.create(null);
this.messageIndex = undefined;
this.keyIndex = undefined;
this.usedKeys = Object.create(null);
var options = this.getOptions();
var first = options && options.length > 0 ? options[0] : null;
if (first) {
if (Array.isArray(first.signatures)) {
first.signatures.forEach(function (signature) { return _this.signatures[signature] = true; });
}
if (Array.isArray(first.ignores)) {
first.ignores.forEach(function (ignore) { return _this.ignores[ignore] = true; });
}
if (typeof first.messageIndex !== 'undefined') {
this.messageIndex = first.messageIndex;
}
if (typeof first.keyIndex !== 'undefined') {
this.keyIndex = first.keyIndex;
}
}
}
NoUnexternalizedStringsRuleWalker.prototype.visitSourceFile = function (node) {
var _this = this;
_super.prototype.visitSourceFile.call(this, node);
Object.keys(this.usedKeys).forEach(function (key) {
var occurences = _this.usedKeys[key];
if (occurences.length > 1) {
occurences.forEach(function (occurence) {
_this.addFailure((_this.createFailure(occurence.key.getStart(), occurence.key.getWidth(), "Duplicate key " + occurence.key.getText() + " with different message value.")));
});
}
});
};
NoUnexternalizedStringsRuleWalker.prototype.visitStringLiteral = function (node) {
this.checkStringLiteral(node);
_super.prototype.visitStringLiteral.call(this, node);
};
NoUnexternalizedStringsRuleWalker.prototype.checkStringLiteral = function (node) {
var text = node.getText();
var doubleQuoted = text.length >= 2 && text[0] === NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE && text[text.length - 1] === NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE;
var info = this.findDescribingParent(node);
// Ignore strings in import and export nodes.
if (info && info.ignoreUsage) {
return;
}
var callInfo = info ? info.callInfo : null;
var functionName = callInfo ? callInfo.callExpression.expression.getText() : null;
if (functionName && this.ignores[functionName]) {
return;
}
if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "Unexternalized string found: " + node.getText()));
return;
}
// We have a single quoted string outside a localize function name.
if (!doubleQuoted && !this.signatures[functionName]) {
return;
}
// We have a string that is a direct argument into the localize call.
var keyArg = callInfo.argIndex === this.keyIndex
? callInfo.callExpression.arguments[this.keyIndex]
: null;
if (keyArg) {
if (isStringLiteral(keyArg)) {
this.recordKey(keyArg, this.messageIndex ? callInfo.callExpression.arguments[this.messageIndex] : undefined);
}
else if (isObjectLiteral(keyArg)) {
for (var i = 0; i < keyArg.properties.length; i++) {
var property = keyArg.properties[i];
if (isPropertyAssignment(property)) {
var name_1 = property.name.getText();
if (name_1 === 'key') {
var initializer = property.initializer;
if (isStringLiteral(initializer)) {
this.recordKey(initializer, this.messageIndex ? callInfo.callExpression.arguments[this.messageIndex] : undefined);
}
break;
}
}
}
}
}
var messageArg = callInfo.argIndex === this.messageIndex
? callInfo.callExpression.arguments[this.messageIndex]
: null;
if (messageArg && messageArg !== node) {
this.addFailure(this.createFailure(messageArg.getStart(), messageArg.getWidth(), "Message argument to '" + callInfo.callExpression.expression.getText() + "' must be a string literal."));
return;
}
};
NoUnexternalizedStringsRuleWalker.prototype.recordKey = function (keyNode, messageNode) {
var text = keyNode.getText();
var occurences = this.usedKeys[text];
if (!occurences) {
occurences = [];
this.usedKeys[text] = occurences;
}
if (messageNode) {
if (occurences.some(function (pair) { return pair.message ? pair.message.getText() === messageNode.getText() : false; })) {
return;
}
}
occurences.push({ key: keyNode, message: messageNode });
};
NoUnexternalizedStringsRuleWalker.prototype.findDescribingParent = function (node) {
var parent;
while ((parent = node.parent)) {
var kind = parent.kind;
if (kind === ts.SyntaxKind.CallExpression) {
var callExpression = parent;
return { callInfo: { callExpression: callExpression, argIndex: callExpression.arguments.indexOf(node) } };
}
else if (kind === ts.SyntaxKind.ImportEqualsDeclaration || kind === ts.SyntaxKind.ImportDeclaration || kind === ts.SyntaxKind.ExportDeclaration) {
return { ignoreUsage: true };
}
else if (kind === ts.SyntaxKind.VariableDeclaration || kind === ts.SyntaxKind.FunctionDeclaration || kind === ts.SyntaxKind.PropertyDeclaration
|| kind === ts.SyntaxKind.MethodDeclaration || kind === ts.SyntaxKind.VariableDeclarationList || kind === ts.SyntaxKind.InterfaceDeclaration
|| kind === ts.SyntaxKind.ClassDeclaration || kind === ts.SyntaxKind.EnumDeclaration || kind === ts.SyntaxKind.ModuleDeclaration
|| kind === ts.SyntaxKind.TypeAliasDeclaration || kind === ts.SyntaxKind.SourceFile) {
return null;
}
node = parent;
}
};
NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE = '"';
return NoUnexternalizedStringsRuleWalker;
}(Lint.RuleWalker));
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var ts = require('typescript');
var Lint = require('tslint/lib/lint');
/**
* Implementation of the no-unexternalized-strings rule.
*/
var Rule = (function (_super) {
__extends(Rule, _super);
function Rule() {
_super.apply(this, arguments);
}
Rule.prototype.apply = function (sourceFile) {
return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions()));
};
return Rule;
}(Lint.Rules.AbstractRule));
exports.Rule = Rule;
function isStringLiteral(node) {
return node && node.kind === ts.SyntaxKind.StringLiteral;
}
function isObjectLiteral(node) {
return node && node.kind === ts.SyntaxKind.ObjectLiteralExpression;
}
function isPropertyAssignment(node) {
return node && node.kind === ts.SyntaxKind.PropertyAssignment;
}
var NoUnexternalizedStringsRuleWalker = (function (_super) {
__extends(NoUnexternalizedStringsRuleWalker, _super);
function NoUnexternalizedStringsRuleWalker(file, opts) {
var _this = this;
_super.call(this, file, opts);
this.signatures = Object.create(null);
this.ignores = Object.create(null);
this.messageIndex = undefined;
this.keyIndex = undefined;
this.usedKeys = Object.create(null);
var options = this.getOptions();
var first = options && options.length > 0 ? options[0] : null;
if (first) {
if (Array.isArray(first.signatures)) {
first.signatures.forEach(function (signature) { return _this.signatures[signature] = true; });
}
if (Array.isArray(first.ignores)) {
first.ignores.forEach(function (ignore) { return _this.ignores[ignore] = true; });
}
if (typeof first.messageIndex !== 'undefined') {
this.messageIndex = first.messageIndex;
}
if (typeof first.keyIndex !== 'undefined') {
this.keyIndex = first.keyIndex;
}
}
}
NoUnexternalizedStringsRuleWalker.prototype.visitSourceFile = function (node) {
var _this = this;
_super.prototype.visitSourceFile.call(this, node);
Object.keys(this.usedKeys).forEach(function (key) {
var occurences = _this.usedKeys[key];
if (occurences.length > 1) {
occurences.forEach(function (occurence) {
_this.addFailure((_this.createFailure(occurence.key.getStart(), occurence.key.getWidth(), "Duplicate key " + occurence.key.getText() + " with different message value.")));
});
}
});
};
NoUnexternalizedStringsRuleWalker.prototype.visitStringLiteral = function (node) {
this.checkStringLiteral(node);
_super.prototype.visitStringLiteral.call(this, node);
};
NoUnexternalizedStringsRuleWalker.prototype.checkStringLiteral = function (node) {
var text = node.getText();
var doubleQuoted = text.length >= 2 && text[0] === NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE && text[text.length - 1] === NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE;
var info = this.findDescribingParent(node);
// Ignore strings in import and export nodes.
if (info && info.ignoreUsage) {
return;
}
var callInfo = info ? info.callInfo : null;
var functionName = callInfo ? callInfo.callExpression.expression.getText() : null;
if (functionName && this.ignores[functionName]) {
return;
}
if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "Unexternalized string found: " + node.getText()));
return;
}
// We have a single quoted string outside a localize function name.
if (!doubleQuoted && !this.signatures[functionName]) {
return;
}
// We have a string that is a direct argument into the localize call.
var keyArg = callInfo.argIndex === this.keyIndex
? callInfo.callExpression.arguments[this.keyIndex]
: null;
if (keyArg) {
if (isStringLiteral(keyArg)) {
this.recordKey(keyArg, this.messageIndex ? callInfo.callExpression.arguments[this.messageIndex] : undefined);
}
else if (isObjectLiteral(keyArg)) {
for (var i = 0; i < keyArg.properties.length; i++) {
var property = keyArg.properties[i];
if (isPropertyAssignment(property)) {
var name_1 = property.name.getText();
if (name_1 === 'key') {
var initializer = property.initializer;
if (isStringLiteral(initializer)) {
this.recordKey(initializer, this.messageIndex ? callInfo.callExpression.arguments[this.messageIndex] : undefined);
}
break;
}
}
}
}
}
var messageArg = callInfo.argIndex === this.messageIndex
? callInfo.callExpression.arguments[this.messageIndex]
: null;
if (messageArg && messageArg !== node) {
this.addFailure(this.createFailure(messageArg.getStart(), messageArg.getWidth(), "Message argument to '" + callInfo.callExpression.expression.getText() + "' must be a string literal."));
return;
}
};
NoUnexternalizedStringsRuleWalker.prototype.recordKey = function (keyNode, messageNode) {
var text = keyNode.getText();
var occurences = this.usedKeys[text];
if (!occurences) {
occurences = [];
this.usedKeys[text] = occurences;
}
if (messageNode) {
if (occurences.some(function (pair) { return pair.message ? pair.message.getText() === messageNode.getText() : false; })) {
return;
}
}
occurences.push({ key: keyNode, message: messageNode });
};
NoUnexternalizedStringsRuleWalker.prototype.findDescribingParent = function (node) {
var parent;
while ((parent = node.parent)) {
var kind = parent.kind;
if (kind === ts.SyntaxKind.CallExpression) {
var callExpression = parent;
return { callInfo: { callExpression: callExpression, argIndex: callExpression.arguments.indexOf(node) } };
}
else if (kind === ts.SyntaxKind.ImportEqualsDeclaration || kind === ts.SyntaxKind.ImportDeclaration || kind === ts.SyntaxKind.ExportDeclaration) {
return { ignoreUsage: true };
}
else if (kind === ts.SyntaxKind.VariableDeclaration || kind === ts.SyntaxKind.FunctionDeclaration || kind === ts.SyntaxKind.PropertyDeclaration
|| kind === ts.SyntaxKind.MethodDeclaration || kind === ts.SyntaxKind.VariableDeclarationList || kind === ts.SyntaxKind.InterfaceDeclaration
|| kind === ts.SyntaxKind.ClassDeclaration || kind === ts.SyntaxKind.EnumDeclaration || kind === ts.SyntaxKind.ModuleDeclaration
|| kind === ts.SyntaxKind.TypeAliasDeclaration || kind === ts.SyntaxKind.SourceFile) {
return null;
}
node = parent;
}
};
NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE = '"';
return NoUnexternalizedStringsRuleWalker;
}(Lint.RuleWalker));
......@@ -274,4 +274,17 @@ exports.rebase = function (count) {
var parts = f.dirname.split(/[\/\\]/);
f.dirname = parts.slice(count).join(path.sep);
});
};
exports.filter = fn => {
const result = es.through(function(data) {
if (fn(data)) {
this.emit('data', data);
} else {
result.restore.push(data);
}
});
result.restore = es.through();
return result;
};
\ No newline at end of file
......@@ -202,7 +202,7 @@ function format(text) {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: true,
PlaceOpenBraceOnNewLineForFunctions: false,
PlaceOpenBraceOnNewLineForControlBlocks: false
PlaceOpenBraceOnNewLineForControlBlocks: false,
};
}
}
......
......@@ -3,72 +3,53 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
// Increase max listeners for event emitters
require('events').EventEmitter.defaultMaxListeners = 100;
var gulp = require('gulp');
var json = require('gulp-json-editor');
var buffer = require('gulp-buffer');
var tsb = require('gulp-tsb');
var filter = require('gulp-filter');
var mocha = require('gulp-mocha');
var es = require('event-stream');
var watch = require('./build/lib/watch');
var nls = require('./build/lib/nls');
var util = require('./build/lib/util');
var reporter = require('./build/lib/reporter')();
var remote = require('gulp-remote-src');
var zip = require('gulp-vinyl-zip');
var path = require('path');
var bom = require('gulp-bom');
var sourcemaps = require('gulp-sourcemaps');
var _ = require('underscore');
var assign = require('object-assign');
var quiet = !!process.env['VSCODE_BUILD_QUIET'];
var monacodts = require('./build/monaco/api');
var fs = require('fs');
var rootDir = path.join(__dirname, 'src');
var tsOptions = {
target: 'ES5',
declaration: true,
module: 'amd',
verbose: !quiet,
preserveConstEnums: true,
experimentalDecorators: true,
sourceMap: true,
rootDir: rootDir,
sourceRoot: util.toFileUri(rootDir)
};
function createFastFilter(filterFn) {
var result = es.through(function(data) {
if (filterFn(data)) {
this.emit('data', data);
} else {
result.restore.push(data);
}
});
result.restore = es.through();
return result;
}
const gulp = require('gulp');
const json = require('gulp-json-editor');
const buffer = require('gulp-buffer');
const tsb = require('gulp-tsb');
const filter = require('gulp-filter');
const mocha = require('gulp-mocha');
const es = require('event-stream');
const watch = require('./build/lib/watch');
const nls = require('./build/lib/nls');
const util = require('./build/lib/util');
const reporter = require('./build/lib/reporter')();
const remote = require('gulp-remote-src');
const zip = require('gulp-vinyl-zip');
const path = require('path');
const bom = require('gulp-bom');
const sourcemaps = require('gulp-sourcemaps');
const _ = require('underscore');
const assign = require('object-assign');
const monacodts = require('./build/monaco/api');
const fs = require('fs');
const rootDir = path.join(__dirname, 'src');
const options = require('./src/tsconfig.json').compilerOptions;
options.verbose = false;
options.sourceMap = true;
options.rootDir = rootDir;
options.sourceRoot = util.toFileUri(rootDir);
function createCompile(build, emitError) {
var opts = _.clone(tsOptions);
const opts = _.clone(options);
opts.inlineSources = !!build;
opts.noFilesystemLookup = true;
var ts = tsb.create(opts, null, null, quiet ? null : function (err) {
reporter(err.toString());
});
const ts = tsb.create(opts, null, null, err => reporter(err.toString()));
return function (token) {
var utf8Filter = createFastFilter(function(data) { return /(\/|\\)test(\/|\\).*utf8/.test(data.path); });
var tsFilter = createFastFilter(function(data) { return /\.ts$/.test(data.path); });
var noDeclarationsFilter = createFastFilter(function(data) { return !(/\.d\.ts$/.test(data.path)); });
const utf8Filter = util.filter(data => /(\/|\\)test(\/|\\).*utf8/.test(data.path));
const tsFilter = util.filter(data => /\.ts$/.test(data.path));
const noDeclarationsFilter = util.filter(data => !(/\.d\.ts$/.test(data.path)));
var input = es.through();
var output = input
const input = es.through();
const output = input
.pipe(utf8Filter)
.pipe(bom())
.pipe(utf8Filter.restore)
......@@ -81,20 +62,20 @@ function createCompile(build, emitError) {
.pipe(sourcemaps.write('.', {
addComment: false,
includeContent: !!build,
sourceRoot: tsOptions.sourceRoot
sourceRoot: options.sourceRoot
}))
.pipe(tsFilter.restore)
.pipe(quiet ? es.through() : reporter.end(emitError));
.pipe(reporter.end(emitError));
return es.duplex(input, output);
};
}
function compileTask(out, build) {
var compile = createCompile(build, true);
const compile = createCompile(build, true);
return function () {
var src = es.merge(
const src = es.merge(
gulp.src('src/**', { base: 'src' }),
gulp.src('node_modules/typescript/lib/lib.d.ts')
);
......@@ -107,14 +88,14 @@ function compileTask(out, build) {
}
function watchTask(out, build) {
var compile = createCompile(build);
const compile = createCompile(build);
return function () {
var src = es.merge(
const src = es.merge(
gulp.src('src/**', { base: 'src' }),
gulp.src('node_modules/typescript/lib/lib.d.ts')
);
var watchSrc = watch('src/**', { base: 'src' });
const watchSrc = watch('src/**', { base: 'src' });
return watchSrc
.pipe(util.incremental(compile, src, true))
......@@ -124,10 +105,9 @@ function watchTask(out, build) {
}
function monacodtsTask(out, isWatch) {
let timer = -1;
var timer = -1;
var runSoon = function(howSoon) {
const runSoon = function(howSoon) {
if (timer !== -1) {
clearTimeout(timer);
timer = -1;
......@@ -138,7 +118,7 @@ function monacodtsTask(out, isWatch) {
}, howSoon);
};
var runNow = function() {
const runNow = function() {
if (timer !== -1) {
clearTimeout(timer);
timer = -1;
......@@ -147,7 +127,7 @@ function monacodtsTask(out, isWatch) {
// monacodts.complainErrors();
// return;
// }
var result = monacodts.run(out);
const result = monacodts.run(out);
if (!result.isTheSame) {
if (isWatch) {
fs.writeFileSync(result.filePath, result.content);
......@@ -157,11 +137,11 @@ function monacodtsTask(out, isWatch) {
}
};
var resultStream;
let resultStream;
if (isWatch) {
var filesToWatchMap = {};
const filesToWatchMap = {};
monacodts.getFilesToWatch(out).forEach(function(filePath) {
filesToWatchMap[path.normalize(filePath)] = true;
});
......@@ -171,7 +151,7 @@ function monacodtsTask(out, isWatch) {
}));
resultStream = es.through(function(data) {
var filePath = path.normalize(data.path);
const filePath = path.normalize(data.path);
if (filesToWatchMap[filePath]) {
runSoon(5000);
}
......@@ -180,7 +160,7 @@ function monacodtsTask(out, isWatch) {
} else {
resultStream = es.through(null, function(end) {
resultStream = es.through(null, function() {
runNow();
this.emit('end');
});
......@@ -220,24 +200,24 @@ gulp.task('test', function () {
});
gulp.task('mixin', function () {
var repo = process.env['VSCODE_MIXIN_REPO'];
const repo = process.env['VSCODE_MIXIN_REPO'];
if (!repo) {
console.log('Missing VSCODE_MIXIN_REPO, skipping mixin');
return;
}
var quality = process.env['VSCODE_QUALITY'];
const quality = process.env['VSCODE_QUALITY'];
if (!quality) {
console.log('Missing VSCODE_QUALITY, skipping mixin');
return;
}
var url = 'https://github.com/' + repo + '/archive/master.zip';
var opts = { base: '' };
var username = process.env['VSCODE_MIXIN_USERNAME'];
var password = process.env['VSCODE_MIXIN_PASSWORD'];
const url = 'https://github.com/' + repo + '/archive/master.zip';
const opts = { base: '' };
const username = process.env['VSCODE_MIXIN_USERNAME'];
const password = process.env['VSCODE_MIXIN_PASSWORD'];
if (username || password) {
opts.auth = { user: username || '', pass: password || '' };
......@@ -245,22 +225,22 @@ gulp.task('mixin', function () {
console.log('Mixing in sources from \'' + url + '\':');
var all = remote(url, opts)
let all = remote(url, opts)
.pipe(zip.src())
.pipe(filter(function (f) { return !f.isDirectory(); }))
.pipe(util.rebase(1));
if (quality) {
var build = all.pipe(filter('build/**'));
var productJsonFilter = filter('product.json', { restore: true });
const build = all.pipe(filter('build/**'));
const productJsonFilter = filter('product.json', { restore: true });
var mixin = all
const mixin = all
.pipe(filter('quality/' + quality + '/**'))
.pipe(util.rebase(2))
.pipe(productJsonFilter)
.pipe(buffer())
.pipe(json(function (patch) {
var original = require('./product.json');
const original = require('./product.json');
return assign(original, patch);
}))
.pipe(productJsonFilter.restore);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册