mirror of
https://github.com/Microsoft/vscode
synced 2024-07-02 15:59:00 +00:00
cleanup top level gulpfile
This commit is contained in:
parent
b6b7e82041
commit
849311713d
|
@ -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;
|
||||
};
|
135
gulpfile.js
135
gulpfile.js
|
@ -3,69 +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 monacodts = require('./build/monaco/api');
|
||||
var fs = require('fs');
|
||||
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');
|
||||
|
||||
var rootDir = path.join(__dirname, 'src');
|
||||
var tsOptions = {
|
||||
target: 'ES5',
|
||||
declaration: true,
|
||||
module: 'amd',
|
||||
verbose: false,
|
||||
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 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, 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)
|
||||
|
@ -78,7 +62,7 @@ function createCompile(build, emitError) {
|
|||
.pipe(sourcemaps.write('.', {
|
||||
addComment: false,
|
||||
includeContent: !!build,
|
||||
sourceRoot: tsOptions.sourceRoot
|
||||
sourceRoot: options.sourceRoot
|
||||
}))
|
||||
.pipe(tsFilter.restore)
|
||||
.pipe(reporter.end(emitError));
|
||||
|
@ -88,10 +72,10 @@ function createCompile(build, emitError) {
|
|||
}
|
||||
|
||||
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')
|
||||
);
|
||||
|
@ -104,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))
|
||||
|
@ -121,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;
|
||||
|
@ -135,7 +118,7 @@ function monacodtsTask(out, isWatch) {
|
|||
}, howSoon);
|
||||
};
|
||||
|
||||
var runNow = function() {
|
||||
const runNow = function() {
|
||||
if (timer !== -1) {
|
||||
clearTimeout(timer);
|
||||
timer = -1;
|
||||
|
@ -144,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);
|
||||
|
@ -154,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;
|
||||
});
|
||||
|
@ -168,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);
|
||||
}
|
||||
|
@ -217,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 || '' };
|
||||
|
@ -242,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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user