Skip to content

Commit

Permalink
pick up quality folder during gulp mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Jan 19, 2016
1 parent a9b3b8c commit dc4cc72
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
45 changes: 41 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
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');
Expand All @@ -22,6 +24,7 @@ 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 rootDir = path.join(__dirname, 'src');
Expand Down Expand Up @@ -119,13 +122,28 @@ gulp.task('test', function () {
.once('end', function () { process.exit(); });
});

function rebase(count) {
return rename(function (f) {
var parts = f.dirname.split(/[\/\\]/);
f.dirname = parts.slice(count).join(path.sep);
});
}

gulp.task('mixin', function () {
var repo = process.env['VSCODE_MIXIN_REPO'];

if (!repo) {
console.log('Missing VSCODE_MIXIN_REPO, skipping mixin');
return;
}

var 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'];
Expand All @@ -136,11 +154,30 @@ gulp.task('mixin', function () {
}

console.log('Mixing in sources from \'' + url + '\':');
return remote(url, opts)

var all = remote(url, opts)
.pipe(zip.src())
.pipe(rename(function (f) {
f.dirname = f.dirname.replace(/^[^\/\\]+[\/\\]?/, '');
}))
.pipe(rebase(1));

if (quality) {
var build = all.pipe(filter('build/**'));
var productJsonFilter = filter('product.json', { restore: true });

var mixin = all
.pipe(filter('quality/' + quality + '/**'))
.pipe(rebase(2))
.pipe(productJsonFilter)
.pipe(buffer())
.pipe(json(function (patch) {
var original = require('./product.json');
return assign(original, patch);
}))
.pipe(productJsonFilter.restore);

all = es.merge(build, mixin);
}

return all
.pipe(es.mapSync(function (f) {
console.log(f.relative);
return f;
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"gulp-atom-electron": "^1.1.0",
"gulp-azure-storage": "^0.3.0",
"gulp-bom": "^1.0.0",
"gulp-buffer": "0.0.2",
"gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.1.0",
"gulp-filter": "^3.0.0",
Expand All @@ -59,12 +60,11 @@
"gulp-sourcemaps": "^1.6.0",
"gulp-symdest": "^1.0.0",
"gulp-tsb": "~1.7.3",
"gulp-tslint": "^4.3.0",
"gulp-uglify": "^1.4.1",
"gulp-util": "^3.0.6",
"gulp-vinyl-zip": "^1.1.0",
"gulp-watch": "^4.2.4",
"gulp-tslint": "^4.3.0",
"tslint-microsoft-contrib": "^2.0.0",
"innosetup-compiler": "^5.5.60",
"istanbul": "^0.3.17",
"jsdom-no-contextify": "^3.1.0",
Expand All @@ -80,6 +80,7 @@
"rimraf": "^2.2.8",
"sinon": "^1.17.2",
"source-map": "^0.4.4",
"tslint-microsoft-contrib": "^2.0.0",
"uglify-js": "2.4.8",
"underscore": "^1.8.2",
"vinyl": "^0.4.5"
Expand Down

0 comments on commit dc4cc72

Please sign in to comment.