From 1c38df7823b50c6ca09e7a721fbf94a373db9cf8 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 11 Jan 2017 11:55:52 +0100 Subject: [PATCH] fixes #18363 --- build/lib/bundle.js | 8 ++--- build/lib/compilation.js | 28 ++++++++-------- build/lib/compilation.ts | 33 ++++++++++--------- build/lib/extensions.js | 6 ++-- build/lib/git.js | 4 +-- build/lib/i18n.js | 12 +++---- build/lib/nls.js | 15 ++++----- build/lib/optimize.js | 32 +++++++++--------- build/lib/reporter.js | 6 ++-- build/lib/tslint/duplicateImportsRule.js | 11 ++++--- build/lib/tslint/importPatternsRule.js | 11 ++++--- build/lib/tslint/layeringRule.js | 11 ++++--- .../lib/tslint/noUnexternalizedStringsRule.js | 33 +++++++++---------- build/lib/util.js | 20 +++++------ build/monaco/api.js | 6 ++-- 15 files changed, 121 insertions(+), 115 deletions(-) diff --git a/build/lib/bundle.js b/build/lib/bundle.js index 9325d6d623f..78375d51eb6 100644 --- a/build/lib/bundle.js +++ b/build/lib/bundle.js @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ "use strict"; -var fs = require('fs'); -var path = require('path'); -var vm = require('vm'); +var fs = require("fs"); +var path = require("path"); +var vm = require("vm"); /** * Bundle `entryPoints` given config `config`. */ @@ -186,7 +186,7 @@ function extractStrings(destFiles) { path: null, contents: [ '(function() {', - ("var __m = " + JSON.stringify(sortedByUseModules) + ";"), + "var __m = " + JSON.stringify(sortedByUseModules) + ";", "var __M = function(deps) {", " var result = [];", " for (var i = 0, len = deps.length; i < len; i++) {", diff --git a/build/lib/compilation.js b/build/lib/compilation.js index da18bdcbc63..2171ffa1ae9 100644 --- a/build/lib/compilation.js +++ b/build/lib/compilation.js @@ -3,19 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; -var gulp = require('gulp'); -var tsb = require('gulp-tsb'); -var es = require('event-stream'); +var gulp = require("gulp"); +var tsb = require("gulp-tsb"); +var es = require("event-stream"); var watch = require('./watch'); -var nls = require('./nls'); -var util = require('./util'); -var reporter_1 = require('./reporter'); -var path = require('path'); -var bom = require('gulp-bom'); -var sourcemaps = require('gulp-sourcemaps'); -var _ = require('underscore'); -var monacodts = require('../monaco/api'); -var fs = require('fs'); +var nls = require("./nls"); +var util = require("./util"); +var reporter_1 = require("./reporter"); +var path = require("path"); +var bom = require("gulp-bom"); +var sourcemaps = require("gulp-sourcemaps"); +var _ = require("underscore"); +var monacodts = require("../monaco/api"); +var fs = require("fs"); var reporter = reporter_1.createReporter(); var rootDir = path.join(__dirname, '../../src'); var options = require('../../src/tsconfig.json').compilerOptions; @@ -23,6 +23,8 @@ options.verbose = false; options.sourceMap = true; options.rootDir = rootDir; options.sourceRoot = util.toFileUri(rootDir); +var smSourceRootPath = path.resolve(path.dirname(rootDir)); +var smSourceRoot = util.toFileUri(smSourceRootPath); function createCompile(build, emitError) { var opts = _.clone(options); opts.inlineSources = !!build; @@ -46,7 +48,7 @@ function createCompile(build, emitError) { .pipe(sourcemaps.write('.', { addComment: false, includeContent: !!build, - sourceRoot: options.sourceRoot + sourceRoot: smSourceRoot })) .pipe(tsFilter.restore) .pipe(reporter.end(emitError)); diff --git a/build/lib/compilation.ts b/build/lib/compilation.ts index eed6a156cbd..ac367a573b0 100644 --- a/build/lib/compilation.ts +++ b/build/lib/compilation.ts @@ -28,14 +28,17 @@ options.sourceMap = true; options.rootDir = rootDir; options.sourceRoot = util.toFileUri(rootDir); -function createCompile(build:boolean, emitError?:boolean): (token?:util.ICancellationToken) => NodeJS.ReadWriteStream { +const smSourceRootPath = path.resolve(path.dirname(rootDir)); +const smSourceRoot = util.toFileUri(smSourceRootPath); + +function createCompile(build: boolean, emitError?: boolean): (token?: util.ICancellationToken) => NodeJS.ReadWriteStream { const opts = _.clone(options); opts.inlineSources = !!build; opts.noFilesystemLookup = true; const ts = tsb.create(opts, null, null, err => reporter(err.toString())); - return function (token?:util.ICancellationToken) { + return function (token?: util.ICancellationToken) { 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))); @@ -54,7 +57,7 @@ function createCompile(build:boolean, emitError?:boolean): (token?:util.ICancell .pipe(sourcemaps.write('.', { addComment: false, includeContent: !!build, - sourceRoot: options.sourceRoot + sourceRoot: smSourceRoot })) .pipe(tsFilter.restore) .pipe(reporter.end(emitError)); @@ -63,7 +66,7 @@ function createCompile(build:boolean, emitError?:boolean): (token?:util.ICancell }; } -export function compileTask(out:string, build:boolean): () => NodeJS.ReadWriteStream { +export function compileTask(out: string, build: boolean): () => NodeJS.ReadWriteStream { const compile = createCompile(build, true); return function () { @@ -79,7 +82,7 @@ export function compileTask(out:string, build:boolean): () => NodeJS.ReadWriteSt }; } -export function watchTask(out:string, build:boolean): () => NodeJS.ReadWriteStream { +export function watchTask(out: string, build: boolean): () => NodeJS.ReadWriteStream { const compile = createCompile(build); return function () { @@ -96,21 +99,21 @@ export function watchTask(out:string, build:boolean): () => NodeJS.ReadWriteStre }; } -function monacodtsTask(out:string, isWatch:boolean): NodeJS.ReadWriteStream { - let timer:NodeJS.Timer = null; +function monacodtsTask(out: string, isWatch: boolean): NodeJS.ReadWriteStream { + let timer: NodeJS.Timer = null; - const runSoon = function(howSoon:number) { + const runSoon = function (howSoon: number) { if (timer !== null) { clearTimeout(timer); timer = null; } - timer = setTimeout(function() { + timer = setTimeout(function () { timer = null; runNow(); }, howSoon); }; - const runNow = function() { + const runNow = function () { if (timer !== null) { clearTimeout(timer); timer = null; @@ -133,16 +136,16 @@ function monacodtsTask(out:string, isWatch:boolean): NodeJS.ReadWriteStream { if (isWatch) { - const filesToWatchMap: {[file:string]:boolean;} = {}; - monacodts.getFilesToWatch(out).forEach(function(filePath) { + const filesToWatchMap: { [file: string]: boolean; } = {}; + monacodts.getFilesToWatch(out).forEach(function (filePath) { filesToWatchMap[path.normalize(filePath)] = true; }); - watch('build/monaco/*').pipe(es.through(function() { + watch('build/monaco/*').pipe(es.through(function () { runSoon(5000); })); - resultStream = es.through(function(data) { + resultStream = es.through(function (data) { const filePath = path.normalize(data.path); if (filesToWatchMap[filePath]) { runSoon(5000); @@ -152,7 +155,7 @@ function monacodtsTask(out:string, isWatch:boolean): NodeJS.ReadWriteStream { } else { - resultStream = es.through(null, function() { + resultStream = es.through(null, function () { runNow(); this.emit('end'); }); diff --git a/build/lib/extensions.js b/build/lib/extensions.js index 70d38f3a5da..f2da7d5fd70 100644 --- a/build/lib/extensions.js +++ b/build/lib/extensions.js @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ "use strict"; -var event_stream_1 = require('event-stream'); -var assign = require('object-assign'); -var remote = require('gulp-remote-src'); +var event_stream_1 = require("event-stream"); +var assign = require("object-assign"); +var remote = require("gulp-remote-src"); var flatmap = require('gulp-flatmap'); var vzip = require('gulp-vinyl-zip'); var filter = require('gulp-filter'); diff --git a/build/lib/git.js b/build/lib/git.js index 973f52ac38e..67163de17de 100644 --- a/build/lib/git.js +++ b/build/lib/git.js @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ "use strict"; -var path = require('path'); -var fs = require('fs'); +var path = require("path"); +var fs = require("fs"); /** * Returns the sha1 commit version of a repository or undefined in case of failure. */ diff --git a/build/lib/i18n.js b/build/lib/i18n.js index 9585915e14f..6af36a8ea48 100644 --- a/build/lib/i18n.js +++ b/build/lib/i18n.js @@ -3,11 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ "use strict"; -var path = require('path'); -var fs = require('fs'); -var event_stream_1 = require('event-stream'); -var File = require('vinyl'); -var Is = require('is'); +var path = require("path"); +var fs = require("fs"); +var event_stream_1 = require("event-stream"); +var File = require("vinyl"); +var Is = require("is"); var util = require('gulp-util'); function log(message) { var rest = []; @@ -233,7 +233,7 @@ function processCoreBundleFormat(fileHeader, json, emitter) { var modules = bundleSection[bundle]; var contents = [ fileHeader, - ("define(\"" + bundle + ".nls." + language.iso639_2 + "\", {") + "define(\"" + bundle + ".nls." + language.iso639_2 + "\", {" ]; modules.forEach(function (module, index) { contents.push("\t\"" + module + "\": ["); diff --git a/build/lib/nls.js b/build/lib/nls.js index 305b2c1487d..e695200d1bd 100644 --- a/build/lib/nls.js +++ b/build/lib/nls.js @@ -1,11 +1,11 @@ "use strict"; -var ts = require('./typescript/typescriptServices'); -var lazy = require('lazy.js'); -var event_stream_1 = require('event-stream'); -var File = require('vinyl'); -var sm = require('source-map'); -var assign = require('object-assign'); -var path = require('path'); +var ts = require("./typescript/typescriptServices"); +var lazy = require("lazy.js"); +var event_stream_1 = require("event-stream"); +var File = require("vinyl"); +var sm = require("source-map"); +var assign = require("object-assign"); +var path = require("path"); var CollectStepResult; (function (CollectStepResult) { CollectStepResult[CollectStepResult["Yes"] = 0] = "Yes"; @@ -71,7 +71,6 @@ function nls() { function isImportNode(node) { return node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */; } -var nls; (function (nls_1) { function fileFrom(file, contents, path) { if (path === void 0) { path = file.path; } diff --git a/build/lib/optimize.js b/build/lib/optimize.js index 43fe511c6a5..91c7658e7de 100644 --- a/build/lib/optimize.js +++ b/build/lib/optimize.js @@ -3,21 +3,21 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; -var path = require('path'); -var gulp = require('gulp'); -var sourcemaps = require('gulp-sourcemaps'); -var filter = require('gulp-filter'); -var minifyCSS = require('gulp-cssnano'); -var uglify = require('gulp-uglify'); -var es = require('event-stream'); -var concat = require('gulp-concat'); -var VinylFile = require('vinyl'); -var bundle = require('./bundle'); -var util = require('./util'); -var i18n = require('./i18n'); -var gulpUtil = require('gulp-util'); -var flatmap = require('gulp-flatmap'); -var pump = require('pump'); +var path = require("path"); +var gulp = require("gulp"); +var sourcemaps = require("gulp-sourcemaps"); +var filter = require("gulp-filter"); +var minifyCSS = require("gulp-cssnano"); +var uglify = require("gulp-uglify"); +var es = require("event-stream"); +var concat = require("gulp-concat"); +var VinylFile = require("vinyl"); +var bundle = require("./bundle"); +var util = require("./util"); +var i18n = require("./i18n"); +var gulpUtil = require("gulp-util"); +var flatmap = require("gulp-flatmap"); +var pump = require("pump"); var REPO_ROOT_PATH = path.join(__dirname, '../..'); function log(prefix, message) { gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message); @@ -208,7 +208,7 @@ function uglifyWithCopyrights() { return es.duplex(input, output); } function minifyTask(src, sourceMapBaseUrl) { - var sourceMappingURL = sourceMapBaseUrl && (function (f) { return (sourceMapBaseUrl + "/" + f.relative + ".map"); }); + var sourceMappingURL = sourceMapBaseUrl && (function (f) { return sourceMapBaseUrl + "/" + f.relative + ".map"; }); return function (cb) { var jsFilter = filter('**/*.js', { restore: true }); var cssFilter = filter('**/*.css', { restore: true }); diff --git a/build/lib/reporter.js b/build/lib/reporter.js index 1efc03b9b57..11f360b551a 100644 --- a/build/lib/reporter.js +++ b/build/lib/reporter.js @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; -var es = require('event-stream'); -var _ = require('underscore'); -var util = require('gulp-util'); +var es = require("event-stream"); +var _ = require("underscore"); +var util = require("gulp-util"); var allErrors = []; var startTime = null; var count = 0; diff --git a/build/lib/tslint/duplicateImportsRule.js b/build/lib/tslint/duplicateImportsRule.js index 2ccfa4fa073..a2d38d6c5c4 100644 --- a/build/lib/tslint/duplicateImportsRule.js +++ b/build/lib/tslint/duplicateImportsRule.js @@ -8,12 +8,12 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var path_1 = require('path'); -var Lint = require('tslint'); +var path_1 = require("path"); +var Lint = require("tslint"); var Rule = (function (_super) { __extends(Rule, _super); function Rule() { - _super.apply(this, arguments); + return _super.apply(this, arguments) || this; } Rule.prototype.apply = function (sourceFile) { return this.applyWithWalker(new ImportPatterns(sourceFile, this.getOptions())); @@ -24,8 +24,9 @@ exports.Rule = Rule; var ImportPatterns = (function (_super) { __extends(ImportPatterns, _super); function ImportPatterns(file, opts) { - _super.call(this, file, opts); - this.imports = Object.create(null); + var _this = _super.call(this, file, opts) || this; + _this.imports = Object.create(null); + return _this; } ImportPatterns.prototype.visitImportDeclaration = function (node) { var path = node.moduleSpecifier.getText(); diff --git a/build/lib/tslint/importPatternsRule.js b/build/lib/tslint/importPatternsRule.js index 1b242c47287..0660f7343bb 100644 --- a/build/lib/tslint/importPatternsRule.js +++ b/build/lib/tslint/importPatternsRule.js @@ -8,12 +8,12 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Lint = require('tslint'); -var minimatch = require('minimatch'); +var Lint = require("tslint"); +var minimatch = require("minimatch"); var Rule = (function (_super) { __extends(Rule, _super); function Rule() { - _super.apply(this, arguments); + return _super.apply(this, arguments) || this; } Rule.prototype.apply = function (sourceFile) { var configs = this.getOptions().ruleArguments; @@ -31,8 +31,9 @@ exports.Rule = Rule; var ImportPatterns = (function (_super) { __extends(ImportPatterns, _super); function ImportPatterns(file, opts, _config) { - _super.call(this, file, opts); - this._config = _config; + var _this = _super.call(this, file, opts) || this; + _this._config = _config; + return _this; } ImportPatterns.prototype.visitImportDeclaration = function (node) { var path = node.moduleSpecifier.getText(); diff --git a/build/lib/tslint/layeringRule.js b/build/lib/tslint/layeringRule.js index 8db7925dddb..87f90e3c5bb 100644 --- a/build/lib/tslint/layeringRule.js +++ b/build/lib/tslint/layeringRule.js @@ -8,12 +8,12 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Lint = require('tslint'); -var path_1 = require('path'); +var Lint = require("tslint"); +var path_1 = require("path"); var Rule = (function (_super) { __extends(Rule, _super); function Rule() { - _super.apply(this, arguments); + return _super.apply(this, arguments) || this; } Rule.prototype.apply = function (sourceFile) { var parts = path_1.dirname(sourceFile.fileName).split(/\\|\//); @@ -44,8 +44,9 @@ exports.Rule = Rule; var LayeringRule = (function (_super) { __extends(LayeringRule, _super); function LayeringRule(file, config, opts) { - _super.call(this, file, opts); - this._config = config; + var _this = _super.call(this, file, opts) || this; + _this._config = config; + return _this; } LayeringRule.prototype.visitImportDeclaration = function (node) { var path = node.moduleSpecifier.getText(); diff --git a/build/lib/tslint/noUnexternalizedStringsRule.js b/build/lib/tslint/noUnexternalizedStringsRule.js index d6c869b20a0..711b80925b2 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.js +++ b/build/lib/tslint/noUnexternalizedStringsRule.js @@ -8,15 +8,15 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var ts = require('typescript'); -var Lint = require('tslint'); +var ts = require("typescript"); +var Lint = require("tslint"); /** * Implementation of the no-unexternalized-strings rule. */ var Rule = (function (_super) { __extends(Rule, _super); function Rule() { - _super.apply(this, arguments); + return _super.apply(this, arguments) || this; } Rule.prototype.apply = function (sourceFile) { return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions())); @@ -36,14 +36,13 @@ function isPropertyAssignment(node) { 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 _this = _super.call(this, file, opts) || this; + _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)) { @@ -53,12 +52,13 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) { first.ignores.forEach(function (ignore) { return _this.ignores[ignore] = true; }); } if (typeof first.messageIndex !== 'undefined') { - this.messageIndex = first.messageIndex; + _this.messageIndex = first.messageIndex; } if (typeof first.keyIndex !== 'undefined') { - this.keyIndex = first.keyIndex; + _this.keyIndex = first.keyIndex; } } + return _this; } NoUnexternalizedStringsRuleWalker.prototype.visitSourceFile = function (node) { var _this = this; @@ -89,7 +89,6 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) { if (functionName && this.ignores[functionName]) { return; } - var x = "foo"; if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) { var s = node.getText(); var replacement = new Lint.Replacement(node.getStart(), node.getWidth(), "nls.localize('KEY-" + s.substring(1, s.length - 1) + "', " + s + ")"); @@ -113,8 +112,8 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) { for (var i = 0; i < keyArg.properties.length; i++) { var property = keyArg.properties[i]; if (isPropertyAssignment(property)) { - var name = property.name.getText(); - if (name === 'key') { + 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); @@ -167,6 +166,6 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) { node = parent; } }; - NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE = '"'; return NoUnexternalizedStringsRuleWalker; }(Lint.RuleWalker)); +NoUnexternalizedStringsRuleWalker.DOUBLE_QUOTE = '"'; diff --git a/build/lib/util.js b/build/lib/util.js index 92dc53cda6c..d25f7961ac3 100644 --- a/build/lib/util.js +++ b/build/lib/util.js @@ -3,16 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; -var es = require('event-stream'); -var debounce = require('debounce'); -var _filter = require('gulp-filter'); -var rename = require('gulp-rename'); -var _ = require('underscore'); -var path = require('path'); -var fs = require('fs'); -var _rimraf = require('rimraf'); -var git = require('./git'); -var VinylFile = require('vinyl'); +var es = require("event-stream"); +var debounce = require("debounce"); +var _filter = require("gulp-filter"); +var rename = require("gulp-rename"); +var _ = require("underscore"); +var path = require("path"); +var fs = require("fs"); +var _rimraf = require("rimraf"); +var git = require("./git"); +var VinylFile = require("vinyl"); var NoCancellationToken = { isCancellationRequested: function () { return false; } }; function incremental(streamProvider, initial, supportsCancellation) { var input = es.through(); diff --git a/build/monaco/api.js b/build/monaco/api.js index 469b19bd79d..393aa8b28db 100644 --- a/build/monaco/api.js +++ b/build/monaco/api.js @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ "use strict"; -var fs = require('fs'); -var ts = require('typescript'); -var path = require('path'); +var fs = require("fs"); +var ts = require("typescript"); +var path = require("path"); var util = require('gulp-util'); function log(message) { var rest = []; -- GitLab