-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathutils.ts
41 lines (33 loc) · 1.26 KB
/
utils.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
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";
import * as ts from "typescript";
import * as fs from "fs";
import * as path from "path";
export function createDefaultFormatCodeOptions(): ts.FormatCodeOptions {
"use strict";
return {
IndentSize: 4,
TabSize: 4,
NewLineCharacter: '\r\n',
ConvertTabsToSpaces: true,
InsertSpaceAfterCommaDelimiter: true,
InsertSpaceAfterSemicolonInForStatements: true,
InsertSpaceBeforeAndAfterBinaryOperators: true,
InsertSpaceAfterKeywordsInControlFlowStatements: true,
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
PlaceOpenBraceOnNewLineForFunctions: false,
PlaceOpenBraceOnNewLineForControlBlocks: false
};
}
export function getConfigFileName(baseDir: string, configFileName: string): string {
"use strict";
let configFilePath = path.resolve(baseDir, configFileName);
if (fs.existsSync(configFilePath)) {
return configFilePath;
}
if (baseDir.length === path.dirname(baseDir).length) {
return null;
}
return getConfigFileName(path.resolve(baseDir, "../"), configFileName);
}