-
Notifications
You must be signed in to change notification settings - Fork 6
/
findTSC.js
25 lines (25 loc) · 950 Bytes
/
findTSC.js
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
var path = require('path');
var fs = require('fs');
var locateTSC;
(function (locateTSC) {
function resolveTypeScriptBinPath() {
var ownRoot = path.resolve(path.dirname((module).filename), '../..');
var userRoot = path.resolve(ownRoot, '..', '..');
var binSub = path.join('node_modules', 'typescript', 'bin');
if (fs.existsSync(path.join(userRoot, binSub))) {
return path.join(userRoot, binSub);
}
return path.join(ownRoot, binSub);
}
function locate(options, results) {
if (options.typeStrongOptions.customCompiler) {
results.runtimeOptions.compiler = options.typeStrongOptions.customCompiler;
}
else {
var binPath = resolveTypeScriptBinPath();
results.runtimeOptions.compiler = path.join(binPath, 'tsc');
}
}
locateTSC.locate = locate;
})(locateTSC || (locateTSC = {}));
exports.default = locateTSC;