未验证 提交 1d27e33c 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #47226 from Microsoft/joh/monaco-typecheck

add monaco-typecheck tasks
...@@ -51,7 +51,6 @@ install: ...@@ -51,7 +51,6 @@ install:
script: script:
- node_modules/.bin/gulp electron --silent - node_modules/.bin/gulp electron --silent
- node_modules/.bin/tsc -p ./src/tsconfig.monaco.json --noEmit
- node_modules/.bin/gulp compile --silent --max_old_space_size=4096 - node_modules/.bin/gulp compile --silent --max_old_space_size=4096
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./scripts/test.sh --coverage --reporter dot; else ./scripts/test.sh --reporter dot; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./scripts/test.sh --coverage --reporter dot; else ./scripts/test.sh --reporter dot; fi
- ./scripts/test-integration.sh - ./scripts/test-integration.sh
......
...@@ -11,7 +11,6 @@ install: ...@@ -11,7 +11,6 @@ install:
build_script: build_script:
- yarn - yarn
- .\node_modules\.bin\gulp electron - .\node_modules\.bin\gulp electron
- .\node_modules\.bin\tsc -p .\src\tsconfig.monaco.json --noEmit
- npm run compile - npm run compile
test_script: test_script:
......
...@@ -93,7 +93,7 @@ gulp.task('clean-minified-editor', util.rimraf('out-editor-min')); ...@@ -93,7 +93,7 @@ gulp.task('clean-minified-editor', util.rimraf('out-editor-min'));
gulp.task('minify-editor', ['clean-minified-editor', 'optimize-editor'], common.minifyTask('out-editor')); gulp.task('minify-editor', ['clean-minified-editor', 'optimize-editor'], common.minifyTask('out-editor'));
gulp.task('clean-editor-esm', util.rimraf('out-editor-esm')); gulp.task('clean-editor-esm', util.rimraf('out-editor-esm'));
gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro'], function() { gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro'], function () {
standalone.createESMSourcesAndResources({ standalone.createESMSourcesAndResources({
entryPoints: [ entryPoints: [
'vs/editor/editor.main', 'vs/editor/editor.main',
...@@ -107,7 +107,7 @@ gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro'], fun ...@@ -107,7 +107,7 @@ gulp.task('extract-editor-esm', ['clean-editor-esm', 'clean-editor-distro'], fun
} }
}); });
}); });
gulp.task('compile-editor-esm', ['extract-editor-esm', 'clean-editor-distro'], function() { gulp.task('compile-editor-esm', ['extract-editor-esm', 'clean-editor-distro'], function () {
const result = cp.spawnSync(`node`, [`../node_modules/.bin/tsc`], { const result = cp.spawnSync(`node`, [`../node_modules/.bin/tsc`], {
cwd: path.join(__dirname, '../out-editor-esm') cwd: path.join(__dirname, '../out-editor-esm')
}); });
...@@ -235,3 +235,60 @@ function filterStream(testFunc) { ...@@ -235,3 +235,60 @@ function filterStream(testFunc) {
this.emit('data', data); this.emit('data', data);
}); });
} }
//#region monaco type checking
function createTscCompileTask(watch) {
return () => {
const createReporter = require('./lib/reporter').createReporter;
return new Promise((resolve, reject) => {
const args = ['./node_modules/.bin/tsc', '-p', './src/tsconfig.monaco.json', '--noEmit'];
if (watch) {
args.push('-w');
}
const child = cp.spawn(`node`, args, {
cwd: path.join(__dirname, '..'),
// stdio: [null, 'pipe', 'inherit']
});
let errors = [];
let reporter = createReporter();
let report;
let magic = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; // https://stackoverflow.com/questions/25245716/remove-all-ansi-colors-styles-from-strings
child.stdout.on('data', data => {
let str = String(data);
str = str.replace(magic, '').trim();
if (str.indexOf('Starting compilation') >= 0 || str.indexOf('File change detected') >= 0) {
errors.length = 0;
report = reporter.end(false);
} else if (str.indexOf('Compilation complete') >= 0) {
report.end();
} else if (str) {
let match = /(.*\(\d+,\d+\): )(.*: )(.*)/.exec(str);
if (match) {
// trying to massage the message so that it matches the gulp-tsb error messages
// e.g. src/vs/base/common/strings.ts(663,5): error TS2322: Type '1234' is not assignable to type 'string'.
let fullpath = path.join(root, match[1]);
let message = match[3];
// @ts-ignore
reporter(fullpath + message);
} else {
// @ts-ignore
reporter(str);
}
}
});
child.on('exit', resolve);
child.on('error', reject);
});
};
}
gulp.task('monaco-typecheck-watch', createTscCompileTask(true));
gulp.task('monaco-typecheck', createTscCompileTask(false));
//#endregion
...@@ -34,7 +34,13 @@ catch (err) { ...@@ -34,7 +34,13 @@ catch (err) {
} }
function log() { function log() {
var errors = _.flatten(allErrors); var errors = _.flatten(allErrors);
errors.map(function (err) { return util.log(util.colors.red('Error') + ": " + err); }); var seen = new Set();
errors.map(function (err) {
if (!seen.has(err)) {
seen.add(err);
util.log(util.colors.red('Error') + ": " + err);
}
});
var regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/; var regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/;
var messages = errors var messages = errors
.map(function (err) { return regex.exec(err); }) .map(function (err) { return regex.exec(err); })
...@@ -80,4 +86,3 @@ function createReporter() { ...@@ -80,4 +86,3 @@ function createReporter() {
return ReportFunc; return ReportFunc;
} }
exports.createReporter = createReporter; exports.createReporter = createReporter;
;
...@@ -11,7 +11,7 @@ import * as util from 'gulp-util'; ...@@ -11,7 +11,7 @@ import * as util from 'gulp-util';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
const allErrors: Error[][] = []; const allErrors: string[][] = [];
let startTime: number = null; let startTime: number = null;
let count = 0; let count = 0;
...@@ -42,7 +42,14 @@ try { ...@@ -42,7 +42,14 @@ try {
function log(): void { function log(): void {
const errors = _.flatten(allErrors); const errors = _.flatten(allErrors);
errors.map(err => util.log(`${util.colors.red('Error')}: ${err}`)); const seen = new Set<string>();
errors.map(err => {
if (!seen.has(err)) {
seen.add(err);
util.log(`${util.colors.red('Error')}: ${err}`);
}
});
const regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/; const regex = /^([^(]+)\((\d+),(\d+)\): (.*)$/;
const messages = errors const messages = errors
...@@ -61,17 +68,17 @@ function log(): void { ...@@ -61,17 +68,17 @@ function log(): void {
} }
export interface IReporter { export interface IReporter {
(err: Error): void; (err: string): void;
hasErrors(): boolean; hasErrors(): boolean;
end(emitError: boolean): NodeJS.ReadWriteStream; end(emitError: boolean): NodeJS.ReadWriteStream;
} }
export function createReporter(): IReporter { export function createReporter(): IReporter {
const errors: Error[] = []; const errors: string[] = [];
allErrors.push(errors); allErrors.push(errors);
class ReportFunc { class ReportFunc {
constructor(err: Error) { constructor(err: string) {
errors.push(err); errors.push(err);
} }
...@@ -97,4 +104,4 @@ export function createReporter(): IReporter { ...@@ -97,4 +104,4 @@ export function createReporter(): IReporter {
} }
return <IReporter><any>ReportFunc; return <IReporter><any>ReportFunc;
}; }
...@@ -28,8 +28,8 @@ gulp.task('default', ['compile']); ...@@ -28,8 +28,8 @@ gulp.task('default', ['compile']);
// All // All
gulp.task('clean', ['clean-client', 'clean-extensions']); gulp.task('clean', ['clean-client', 'clean-extensions']);
gulp.task('compile', ['compile-client', 'compile-extensions']); gulp.task('compile', ['monaco-typecheck', 'compile-client', 'compile-extensions']);
gulp.task('watch', ['watch-client', 'watch-extensions']); gulp.task('watch', ['monaco-typecheck-watch', 'watch-client', 'watch-extensions']);
// All Build // All Build
gulp.task('clean-build', ['clean-client-build', 'clean-extensions-build']); gulp.task('clean-build', ['clean-client-build', 'clean-extensions-build']);
...@@ -74,4 +74,4 @@ if (runningEditorTasks) { ...@@ -74,4 +74,4 @@ if (runningEditorTasks) {
const build = path.join(__dirname, 'build'); const build = path.join(__dirname, 'build');
require('glob').sync('gulpfile.*.js', { cwd: build }) require('glob').sync('gulpfile.*.js', { cwd: build })
.forEach(f => require(`./build/${f}`)); .forEach(f => require(`./build/${f}`));
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册