Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
ivogabe committed Feb 9, 2016
1 parent 1d907f1 commit 3271541
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 31 deletions.
26 changes: 4 additions & 22 deletions release/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,6 @@ var File;
}
File.getChangeState = getChangeState;
})(File = exports.File || (exports.File = {}));
/**
* Finds the common base path of two directories
*/
function getCommonBasePath(a, b) {
var aSplit = a.split(/\\|\//); // Split on '/' or '\'.
var bSplit = b.split(/\\|\//);
var commonLength = 0;
for (var i = 0; i < aSplit.length && i < bSplit.length; i++) {
if (aSplit[i] !== bSplit[i])
break;
commonLength += aSplit[i].length + 1;
}
return a.substr(0, commonLength);
}
var FileDictionary = (function () {
function FileDictionary(typescript) {
this.files = {};
Expand Down Expand Up @@ -123,12 +109,10 @@ var FileDictionary = (function () {
get: function () {
var _this = this;
var fileNames = this.getSourceFileNames(true);
return fileNames
.map(function (fileName) {
return utils.getCommonBasePathOfArray(fileNames.map(function (fileName) {
var file = _this.files[utils.normalizePath(fileName)];
return path.resolve(process.cwd(), file.gulp.base);
})
.reduce(getCommonBasePath);
}));
},
enumerable: true,
configurable: true
Expand All @@ -137,12 +121,10 @@ var FileDictionary = (function () {
get: function () {
var _this = this;
var fileNames = this.getSourceFileNames();
return fileNames
.map(function (fileName) {
return utils.getCommonBasePathOfArray(fileNames.map(function (fileName) {
var file = _this.files[utils.normalizePath(fileName)];
return path.dirname(file.fileNameNormalized);
})
.reduce(getCommonBasePath);
}));
},
enumerable: true,
configurable: true
Expand Down
2 changes: 2 additions & 0 deletions release/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ var Output = (function () {
this.results = results;
if (this.project.reporter.finish)
this.project.reporter.finish(results);
this.streamJs.emit('finish');
this.streamDts.emit('finish');
this.streamJs.push(null);
this.streamDts.push(null);
};
Expand Down
38 changes: 29 additions & 9 deletions release/project.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
///<reference path='../typings/tsd.d.ts'/>
var stream = require('stream');
var ts = require('typescript');
var vfs = require('vinyl-fs');
var path = require('path');
Expand Down Expand Up @@ -35,23 +36,42 @@ var Project = (function () {
if (this.config.compilerOptions && this.config.compilerOptions.rootDir) {
base = path.resolve(configPath, this.config.compilerOptions.rootDir);
}
else {
base = configPath;
}
if (!this.config.files) {
var files = [path.join(base, '**/*.ts')];
var files_1 = [path.join(configPath, '**/*.ts')];
if (tsApi.isTS16OrNewer(this.typescript)) {
files.push(path.join(base, '**/*.tsx'));
files_1.push(path.join(configPath, '**/*.tsx'));
}
if (this.config.exclude instanceof Array) {
files = files.concat(
files_1 = files_1.concat(
// Exclude files
this.config.exclude.map(function (file) { return '!' + path.resolve(base, file); }),
this.config.exclude.map(function (file) { return '!' + path.resolve(configPath, file); }),
// Exclude directories
this.config.exclude.map(function (file) { return '!' + path.resolve(base, file) + '/**/*'; }));
this.config.exclude.map(function (file) { return '!' + path.resolve(configPath, file) + '/**/*'; }));
}
if (base !== undefined) {
return vfs.src(files_1, { base: base });
}
return vfs.src(files);
var srcStream = vfs.src(files_1);
var sources = new stream.Readable({ objectMode: true });
sources._read = function () { };
var resolvedFiles_1 = [];
srcStream.on('data', function (file) {
resolvedFiles_1.push(file);
});
srcStream.on('finish', function () {
var base = utils.getCommonBasePathOfArray(resolvedFiles_1.map(function (file) { return path.dirname(file.path); }));
for (var _i = 0; _i < resolvedFiles_1.length; _i++) {
var file = resolvedFiles_1[_i];
file.base = base;
sources.push(file);
}
sources.emit('finish');
});
return srcStream;
}
var files = this.config.files.map(function (file) { return path.resolve(configPath, file); });
if (base === undefined)
base = utils.getCommonBasePathOfArray(files.map(function (file) { return path.dirname(file); }));
var resolvedFiles = [];
var checkMissingFiles = through2.obj(function (file, enc, callback) {
this.push(file);
Expand Down
21 changes: 21 additions & 0 deletions release/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,24 @@ function splitExtension(fileName, knownExtensions) {
return [fileName.substr(0, index - 1), ext];
}
exports.splitExtension = splitExtension;
/**
* Finds the common base path of two directories
*/
function getCommonBasePath(a, b) {
var aSplit = a.split(/\\|\//); // Split on '/' or '\'.
var bSplit = b.split(/\\|\//);
var commonLength = 0;
for (var i = 0; i < aSplit.length && i < bSplit.length; i++) {
if (aSplit[i] !== bSplit[i])
break;
commonLength += aSplit[i].length + 1;
}
return a.substr(0, commonLength);
}
exports.getCommonBasePath = getCommonBasePath;
function getCommonBasePathOfArray(paths) {
if (paths.length === 0)
return '';
return paths.reduce(getCommonBasePath);
}
exports.getCommonBasePathOfArray = getCommonBasePathOfArray;

0 comments on commit 3271541

Please sign in to comment.