Skip to content

Commit 788a543

Browse files
committed
Minor improvements
1 parent 5b6075e commit 788a543

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

file-mixin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
const createHash = Npm.require('crypto').createHash;
2+
13
FileMixin = {
4+
id() {
5+
let hash = createHash('sha1');
6+
let path = this.getPathInPackage();
7+
let fileHash = this.getSourceHash();
8+
let fileId = hash.update(path + fileHash).digest('hex');
9+
return fileId;
10+
},
11+
212
warn(error) {
313
console.log(`${error.sourcePath} (${error.line}, ${error.column}): ${error.message}`);
414
},

package.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Package.describe({
22
name: 'barbatus:typescript-compiler',
3-
version: '0.5.6',
3+
version: '0.5.7',
44
summary: 'TypeScript Compiler for Meteor',
55
git: 'https://github.com/barbatus/ts-compilers',
66
documentation: 'README.md'
77
});
88

99
Npm.depends({
10-
'meteor-typescript': '0.6.2',
10+
'meteor-typescript': '0.6.4',
1111
'async': '1.4.0',
1212
'minimatch': '3.0.0'
1313
});

typescript-compiler.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ TypeScriptCompiler = class TypeScriptCompiler {
5252
let buildOptions = { compilerOptions, typings, useCache };
5353

5454
let dcompile = Logger.newDebug('compilation');
55-
const future = new Future;
56-
async.each(_.keys(archMap), (arch, cb) => {
55+
_.keys(archMap).forEach((arch, cb) => {
5756
let archFiles = archMap[arch];
5857
let filePaths = archFiles.map(inputFile => this.getExtendedPath(inputFile));
5958
dcompile.log('process files: %s', filePaths);
@@ -62,8 +61,9 @@ TypeScriptCompiler = class TypeScriptCompiler {
6261
let dbuild = Logger.newDebug('tsBuild');
6362
let tsBuild = new TSBuild(filePaths, getFileContent, buildOptions);
6463

65-
archFiles.forEach(inputFile => {
66-
if (inputFile.isDeclaration()) return;
64+
let future = new Future;
65+
async.each(archFiles, (inputFile, cb) => {
66+
if (inputFile.isDeclaration()) { cb(); return; };
6767

6868
let co = compilerOptions;
6969
let source = inputFile.getContentsAsString();
@@ -93,14 +93,14 @@ TypeScriptCompiler = class TypeScriptCompiler {
9393
toBeAdded.sourceMap = result.sourceMap;
9494

9595
inputFile.addJavaScript(toBeAdded);
96-
});
9796

98-
cb();
97+
cb();
98+
}, future.resolver());
9999

100-
dbuild.end();
101-
}, future.resolver());
100+
future.wait();
102101

103-
future.wait();
102+
dbuild.end();
103+
});
104104

105105
dcompile.end();
106106
}
@@ -196,8 +196,9 @@ TypeScriptCompiler = class TypeScriptCompiler {
196196
let dexclude = Logger.newDebug('exclude');
197197
for (let ex of this.tsconfig.exclude) {
198198
resultFiles = resultFiles.filter(inputFile => {
199-
dexclude.log('exclude pattern %s', ex);
200-
return ! minimatch(inputFile.getPathInPackage(), ex);
199+
let path = inputFile.getPathInPackage();
200+
dexclude.log('exclude pattern %s: %s', ex, path);
201+
return ! minimatch(path, ex);
201202
});
202203
}
203204
dexclude.end();

0 commit comments

Comments
 (0)