Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Fix the error when outDir compiler option is specified #27

Merged
merged 1 commit into from
Feb 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ namespace tss {
throw new Error(this.formatDiagnostics(allDiagnostics));
}

var outputFileName = FILENAME_TS.replace(/ts$/, 'js');
var outDir = 'outDir' in this.options ? this.options.outDir : '.';
var outputFileName = path.join(outDir, FILENAME_TS.replace(/ts$/, 'js'));
var file = output.outputFiles.filter((file) => file.name === outputFileName)[0];
var text = file.text;

Expand Down
14 changes: 14 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,18 @@ describe('typescript-update', function() {
assert.equal(tss.compile(src, srcFile), expected);
});
});

context('tss outDir option is specified', function() {
var tss;
beforeEach(function() {
tss = new TypeScriptSimple({outDir: 'built/'}, false);
});

it('compares output file names with the name with outDir', function() {
var src = "var x = 123;";
assert.doesNotThrow(function() {
tss.compile(src);
}, /Cannot read property 'text'/);
});
});
});