Merge pull request #2450 from Microsoft/tsconfigServer

Add support to TypeScript server for tsconfig.json files.
This commit is contained in:
Steve Lucco
2015-03-24 14:38:26 -07:00
13 changed files with 248 additions and 109 deletions

View File

@@ -10,6 +10,22 @@ module ts {
/** The version of the TypeScript compiler release */
export let version = "1.5.0.0";
export function findConfigFile(searchPath: string): string {
var fileName = "tsconfig.json";
while (true) {
if (sys.fileExists(fileName)) {
return fileName;
}
var parentPath = getDirectoryPath(searchPath);
if (parentPath === searchPath) {
break;
}
searchPath = parentPath;
fileName = "../" + fileName;
}
return undefined;
}
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
let currentDirectory: string;
let existingDirectories: Map<boolean> = {};

View File

@@ -132,23 +132,6 @@ module ts {
return typeof JSON === "object" && typeof JSON.parse === "function";
}
function findConfigFile(): string {
var searchPath = normalizePath(sys.getCurrentDirectory());
var fileName = "tsconfig.json";
while (true) {
if (sys.fileExists(fileName)) {
return fileName;
}
var parentPath = getDirectoryPath(searchPath);
if (parentPath === searchPath) {
break;
}
searchPath = parentPath;
fileName = "../" + fileName;
}
return undefined;
}
export function executeCommandLine(args: string[]): void {
var commandLine = parseCommandLine(args);
var configFileName: string; // Configuration file name (if any)
@@ -198,7 +181,8 @@ module ts {
}
}
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
configFileName = findConfigFile();
var searchPath = normalizePath(sys.getCurrentDirectory());
configFileName = findConfigFile(searchPath);
}
if (commandLine.fileNames.length === 0 && !configFileName) {