-
Notifications
You must be signed in to change notification settings - Fork 6
/
locateTSC.ts
29 lines (23 loc) · 956 Bytes
/
locateTSC.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as path from 'path';
import * as fs from 'fs';
import i from 'interfaces';
module locateTSC {
"use strict";
// TODO: log the actual version used in verbose mode...
// grunt.log.writeln('Using tsc v' + pkg.version);
// var pkg = JSON.parse(fs.readFileSync(path.resolve(binPath, '..', 'package.json')).toString());
function resolveTypeScriptBinPath(): string {
var ownRoot = path.resolve(path.dirname((module).filename));
var binSub = path.join('node_modules', 'typescript', 'bin');
return path.join(ownRoot, binSub);
}
export function locate(options: i.compilerOptions, results: i.compilerResult): void {
if (options.typeStrongOptions.customCompiler) {
results.runtimeOptions.compiler = options.typeStrongOptions.customCompiler;
} else {
var binPath = resolveTypeScriptBinPath();
results.runtimeOptions.compiler = path.join(binPath, 'tsc');
}
}
}
export {locateTSC as default};