From 025c5430d663206925971580e3d2cce1b64fc834 Mon Sep 17 00:00:00 2001 From: vvakame Date: Mon, 27 Feb 2017 18:31:40 +0900 Subject: [PATCH] feat(tsfmt): add --useTsconfig, --useTsfmt, --useTslint options to CLI closes #67 --- README.md | 23 +++-- lib/cli.ts | 25 +++++ lib/index.ts | 3 + lib/provider/base.ts | 7 +- lib/provider/tsconfigjson.ts | 7 +- lib/provider/tslintjson.ts | 15 ++- .../specified-config/tsconfig/main.json | 17 ++++ .../specified-config/tsconfig/main.ts | 6 ++ .../expected/specified-config/tsfmt/main.json | 17 ++++ test/expected/specified-config/tsfmt/main.ts | 7 ++ .../specified-config/tslint/main.json | 17 ++++ test/expected/specified-config/tslint/main.ts | 6 ++ .../tsconfig/alt-tsconfig.json | 5 + .../fixture/specified-config/tsconfig/main.ts | 6 ++ .../specified-config/tsconfig/tsconfig.json | 5 + .../specified-config/tsfmt/alt-tsfmt.json | 17 ++++ test/fixture/specified-config/tsfmt/main.ts | 6 ++ .../fixture/specified-config/tsfmt/tsfmt.json | 17 ++++ .../specified-config/tslint/alt-tslint.json | 5 + test/fixture/specified-config/tslint/main.ts | 6 ++ .../specified-config/tslint/tslint.json | 5 + test/indexSpec.ts | 96 ++++++++++++++++++- 22 files changed, 300 insertions(+), 18 deletions(-) create mode 100644 test/expected/specified-config/tsconfig/main.json create mode 100644 test/expected/specified-config/tsconfig/main.ts create mode 100644 test/expected/specified-config/tsfmt/main.json create mode 100644 test/expected/specified-config/tsfmt/main.ts create mode 100644 test/expected/specified-config/tslint/main.json create mode 100644 test/expected/specified-config/tslint/main.ts create mode 100644 test/fixture/specified-config/tsconfig/alt-tsconfig.json create mode 100644 test/fixture/specified-config/tsconfig/main.ts create mode 100644 test/fixture/specified-config/tsconfig/tsconfig.json create mode 100644 test/fixture/specified-config/tsfmt/alt-tsfmt.json create mode 100644 test/fixture/specified-config/tsfmt/main.ts create mode 100644 test/fixture/specified-config/tsfmt/tsfmt.json create mode 100644 test/fixture/specified-config/tslint/alt-tslint.json create mode 100644 test/fixture/specified-config/tslint/main.ts create mode 100644 test/fixture/specified-config/tslint/tslint.json diff --git a/README.md b/README.md index 98e733d..97d8192 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,19 @@ $ tsfmt --help Options: - -r, --replace replace .ts file - --verify checking file format - --baseDir config file lookup from - --stdin get formatting content from stdin - --no-tsconfig don't read a tsconfig.json - --no-tslint don't read a tslint.json - --no-editorconfig don't read a .editorconfig - --no-vscode don't read a .vscode/settings.json - --no-tsfmt don't read a tsfmt.json - --verbose makes output more verbose + -r, --replace replace .ts file + --verify checking file format + --baseDir config file lookup from + --stdin get formatting content from stdin + --no-tsconfig don't read a tsconfig.json + --no-tslint don't read a tslint.json + --no-editorconfig don't read a .editorconfig + --no-vscode don't read a .vscode/settings.json + --no-tsfmt don't read a tsfmt.json + --useTsconfig using specified config file insteaf of tsconfig.json + --useTslint using specified config file insteaf of tslint.json + --useTsfmt using specified config file insteaf of tsfmt.json + --verbose makes output more verbose ``` ## Installation diff --git a/lib/cli.ts b/lib/cli.ts index e5b5432..c1b30ff 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -12,6 +12,7 @@ try { } import * as fs from "fs"; +import * as path from "path"; import * as commandpost from "commandpost"; import * as lib from "./"; @@ -29,6 +30,9 @@ interface RootOptions { editorconfig: boolean; vscode: boolean; tsfmt: boolean; + useTsconfig: string[]; + useTslint: string[]; + useTsfmt: string[]; verbose: boolean; } @@ -48,6 +52,9 @@ let root = commandpost .option("--no-editorconfig", "don't read a .editorconfig") .option("--no-vscode", "don't read a .vscode/settings.json") .option("--no-tsfmt", "don't read a tsfmt.json") + .option("--useTsconfig ", "using specified config file insteaf of tsconfig.json") + .option("--useTslint ", "using specified config file insteaf of tslint.json") + .option("--useTsfmt ", "using specified config file insteaf of tsfmt.json") .option("--verbose", "makes output more verbose") .action((opts, args) => { let replace = !!opts.replace; @@ -59,6 +66,9 @@ let root = commandpost let editorconfig = !!opts.editorconfig; let vscode = !!opts.vscode; let tsfmt = !!opts.tsfmt; + let tsconfigFile = opts.useTsconfig[0] ? path.join(process.cwd(), opts.useTsconfig[0]) : null; + let tslintFile = opts.useTslint[0] ? path.join(process.cwd(), opts.useTslint[0]) : null; + let tsfmtFile = opts.useTsfmt[0] ? path.join(process.cwd(), opts.useTsfmt[0]) : null; let verbose = !!opts.verbose; let files = args.files; @@ -86,10 +96,19 @@ let root = commandpost console.log("stdin: " + (stdin ? "ON" : "OFF")); console.log("files from tsconfig: " + (useTsconfig ? "ON" : "OFF")); console.log("tsconfig: " + (tsconfig ? "ON" : "OFF")); + if (tsconfigFile) { + console.log("specified tsconfig.json: " + tsconfigFile); + } console.log("tslint: " + (tslint ? "ON" : "OFF")); + if (tslintFile) { + console.log("specified tslint.json: " + tslintFile); + } console.log("editorconfig: " + (editorconfig ? "ON" : "OFF")); console.log("vscode: " + (vscode ? "ON" : "OFF")); console.log("tsfmt: " + (tsfmt ? "ON" : "OFF")); + if (tsfmtFile) { + console.log("specified tsfmt.json: " + tsfmtFile); + } } if (stdin) { @@ -103,10 +122,13 @@ let root = commandpost verify: verify, baseDir: baseDir, tsconfig: tsconfig, + tsconfigFile: tsconfigFile, tslint: tslint, + tslintFile: tslintFile, editorconfig: editorconfig, vscode: vscode, tsfmt: tsfmt, + tsfmtFile: tsfmtFile, verbose: verbose, }) .then(result => { @@ -123,10 +145,13 @@ let root = commandpost verify: verify, baseDir: baseDir, tsconfig: tsconfig, + tsconfigFile: tsconfigFile, tslint: tslint, + tslintFile: tslintFile, editorconfig: editorconfig, vscode: vscode, tsfmt: tsfmt, + tsfmtFile: tsfmtFile, verbose: verbose, }) .then(showResultHandler) diff --git a/lib/index.ts b/lib/index.ts index 3773c56..2116ea4 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -19,10 +19,13 @@ export interface Options { replace: boolean; verify: boolean; tsconfig: boolean; + tsconfigFile: string | null; tslint: boolean; + tslintFile: string | null; editorconfig: boolean; vscode: boolean; tsfmt: boolean; + tsfmtFile: string | null; } export interface OptionModifier { diff --git a/lib/provider/base.ts b/lib/provider/base.ts index d693732..84e83b2 100644 --- a/lib/provider/base.ts +++ b/lib/provider/base.ts @@ -38,7 +38,12 @@ interface TsfmtSettings { export default function makeFormatCodeOptions(fileName: string, opts: Options, formatSettings: ts.FormatCodeSettings): ts.FormatCodeSettings { let baseDir = opts.baseDir ? path.resolve(opts.baseDir) : path.dirname(path.resolve(fileName)); - let configFileName = getConfigFileName(baseDir, "tsfmt.json"); + let configFileName: string | null; + if (opts.tsfmtFile && path.isAbsolute(opts.tsfmtFile)) { + configFileName = opts.tsfmtFile; + } else { + configFileName = getConfigFileName(baseDir, opts.tsfmtFile || "tsfmt.json"); + } if (!configFileName) { return formatSettings; } diff --git a/lib/provider/tsconfigjson.ts b/lib/provider/tsconfigjson.ts index 28078be..aed5c9e 100644 --- a/lib/provider/tsconfigjson.ts +++ b/lib/provider/tsconfigjson.ts @@ -9,7 +9,12 @@ import { getConfigFileName, parseJSON } from "../utils"; export default function makeFormatCodeOptions(fileName: string, opts: Options, formatSettings: ts.FormatCodeSettings): ts.FormatCodeSettings { let baseDir = opts.baseDir ? path.resolve(opts.baseDir) : path.dirname(path.resolve(fileName)); - let configFileName = getConfigFileName(baseDir, "tsconfig.json"); + let configFileName: string | null; + if (opts.tsconfigFile && path.isAbsolute(opts.tsconfigFile)) { + configFileName = opts.tsconfigFile; + } else { + configFileName = getConfigFileName(baseDir, opts.tsconfigFile || "tsconfig.json"); + } if (!configFileName) { return formatSettings; } diff --git a/lib/provider/tslintjson.ts b/lib/provider/tslintjson.ts index 997d3e2..2f4052d 100644 --- a/lib/provider/tslintjson.ts +++ b/lib/provider/tslintjson.ts @@ -32,10 +32,16 @@ export interface AdditionalFormatSettings { export default function makeFormatCodeOptions(fileName: string, opts: Options, formatSettings: ts.FormatCodeSettings): ts.FormatCodeSettings { let baseDir = opts.baseDir ? path.resolve(opts.baseDir) : path.dirname(path.resolve(fileName)); - let configFileName = getConfigFileName(baseDir, "tslint.json"); + let configFileName: string | null; + if (opts.tslintFile && path.isAbsolute(opts.tslintFile)) { + configFileName = opts.tslintFile; + } else { + configFileName = getConfigFileName(baseDir, opts.tslintFile || "tslint.json"); + } if (!configFileName) { return formatSettings; } + if (opts.verbose) { console.log(`read ${configFileName} for ${fileName}`); } @@ -75,7 +81,12 @@ export default function makeFormatCodeOptions(fileName: string, opts: Options, f export function postProcess(fileName: string, formattedCode: string, opts: Options, _formatSettings: ts.FormatCodeSettings): string { let baseDir = opts.baseDir ? path.resolve(opts.baseDir) : path.dirname(path.resolve(fileName)); - let configFileName = getConfigFileName(baseDir, "tslint.json"); + let configFileName: string | null; + if (opts.tslintFile && path.isAbsolute(opts.tslintFile)) { + configFileName = opts.tslintFile; + } else { + configFileName = getConfigFileName(baseDir, opts.tslintFile || "tslint.json"); + } if (!configFileName) { return formattedCode; } diff --git a/test/expected/specified-config/tsconfig/main.json b/test/expected/specified-config/tsconfig/main.json new file mode 100644 index 0000000..9734eee --- /dev/null +++ b/test/expected/specified-config/tsconfig/main.json @@ -0,0 +1,17 @@ +{ + "indentSize": 4, + "tabSize": 4, + "indentStyle": 2, + "newLineCharacter": "\n", + "convertTabsToSpaces": true, + "insertSpaceAfterCommaDelimiter": true, + "insertSpaceAfterSemicolonInForStatements": true, + "insertSpaceBeforeAndAfterBinaryOperators": true, + "insertSpaceAfterKeywordsInControlFlowStatements": true, + "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, + "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, + "placeOpenBraceOnNewLineForFunctions": false, + "placeOpenBraceOnNewLineForControlBlocks": false +} \ No newline at end of file diff --git a/test/expected/specified-config/tsconfig/main.ts b/test/expected/specified-config/tsconfig/main.ts new file mode 100644 index 0000000..48296fc --- /dev/null +++ b/test/expected/specified-config/tsconfig/main.ts @@ -0,0 +1,6 @@ +class Sample { + hello(word: string = "world"): string { return "Hello, " + word; } +} + +var s: Sample = new Sample(); +if (s === s) { console.log(s.hello()); } diff --git a/test/expected/specified-config/tsfmt/main.json b/test/expected/specified-config/tsfmt/main.json new file mode 100644 index 0000000..beb6aaa --- /dev/null +++ b/test/expected/specified-config/tsfmt/main.json @@ -0,0 +1,17 @@ +{ + "indentSize": 4, + "tabSize": 4, + "indentStyle": 2, + "newLineCharacter": "\n", + "convertTabsToSpaces": true, + "insertSpaceAfterCommaDelimiter": true, + "insertSpaceAfterSemicolonInForStatements": true, + "insertSpaceBeforeAndAfterBinaryOperators": true, + "insertSpaceAfterKeywordsInControlFlowStatements": true, + "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true, + "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true, + "placeOpenBraceOnNewLineForFunctions": true, + "placeOpenBraceOnNewLineForControlBlocks": true +} \ No newline at end of file diff --git a/test/expected/specified-config/tsfmt/main.ts b/test/expected/specified-config/tsfmt/main.ts new file mode 100644 index 0000000..596f40f --- /dev/null +++ b/test/expected/specified-config/tsfmt/main.ts @@ -0,0 +1,7 @@ +class Sample +{ + hello( word: string = "world" ): string { return "Hello, " + word; } +} + +var s: Sample = new Sample(); +if ( s === s ) { console.log( s.hello() ); } diff --git a/test/expected/specified-config/tslint/main.json b/test/expected/specified-config/tslint/main.json new file mode 100644 index 0000000..4eafe49 --- /dev/null +++ b/test/expected/specified-config/tslint/main.json @@ -0,0 +1,17 @@ +{ + "indentSize": 4, + "tabSize": 4, + "indentStyle": 2, + "newLineCharacter": "\r\n", + "convertTabsToSpaces": false, + "insertSpaceAfterCommaDelimiter": true, + "insertSpaceAfterSemicolonInForStatements": true, + "insertSpaceBeforeAndAfterBinaryOperators": true, + "insertSpaceAfterKeywordsInControlFlowStatements": true, + "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, + "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, + "placeOpenBraceOnNewLineForFunctions": false, + "placeOpenBraceOnNewLineForControlBlocks": false +} \ No newline at end of file diff --git a/test/expected/specified-config/tslint/main.ts b/test/expected/specified-config/tslint/main.ts new file mode 100644 index 0000000..c7162f9 --- /dev/null +++ b/test/expected/specified-config/tslint/main.ts @@ -0,0 +1,6 @@ +class Sample { + hello(word: string = "world"): string { return "Hello, " + word; } +} + +var s: Sample = new Sample(); +if (s === s) { console.log(s.hello()); } diff --git a/test/fixture/specified-config/tsconfig/alt-tsconfig.json b/test/fixture/specified-config/tsconfig/alt-tsconfig.json new file mode 100644 index 0000000..7429bdc --- /dev/null +++ b/test/fixture/specified-config/tsconfig/alt-tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "newLine": "LF" + } +} \ No newline at end of file diff --git a/test/fixture/specified-config/tsconfig/main.ts b/test/fixture/specified-config/tsconfig/main.ts new file mode 100644 index 0000000..8ee345f --- /dev/null +++ b/test/fixture/specified-config/tsconfig/main.ts @@ -0,0 +1,6 @@ +class Sample { +hello(word:string="world"):string{return "Hello, " + word;} +} + +var s:Sample=new Sample(); +if(s===s){console.log(s.hello());} diff --git a/test/fixture/specified-config/tsconfig/tsconfig.json b/test/fixture/specified-config/tsconfig/tsconfig.json new file mode 100644 index 0000000..7bae2ef --- /dev/null +++ b/test/fixture/specified-config/tsconfig/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "newLine": "CRLF" + } +} \ No newline at end of file diff --git a/test/fixture/specified-config/tsfmt/alt-tsfmt.json b/test/fixture/specified-config/tsfmt/alt-tsfmt.json new file mode 100644 index 0000000..beb6aaa --- /dev/null +++ b/test/fixture/specified-config/tsfmt/alt-tsfmt.json @@ -0,0 +1,17 @@ +{ + "indentSize": 4, + "tabSize": 4, + "indentStyle": 2, + "newLineCharacter": "\n", + "convertTabsToSpaces": true, + "insertSpaceAfterCommaDelimiter": true, + "insertSpaceAfterSemicolonInForStatements": true, + "insertSpaceBeforeAndAfterBinaryOperators": true, + "insertSpaceAfterKeywordsInControlFlowStatements": true, + "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true, + "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true, + "placeOpenBraceOnNewLineForFunctions": true, + "placeOpenBraceOnNewLineForControlBlocks": true +} \ No newline at end of file diff --git a/test/fixture/specified-config/tsfmt/main.ts b/test/fixture/specified-config/tsfmt/main.ts new file mode 100644 index 0000000..8ee345f --- /dev/null +++ b/test/fixture/specified-config/tsfmt/main.ts @@ -0,0 +1,6 @@ +class Sample { +hello(word:string="world"):string{return "Hello, " + word;} +} + +var s:Sample=new Sample(); +if(s===s){console.log(s.hello());} diff --git a/test/fixture/specified-config/tsfmt/tsfmt.json b/test/fixture/specified-config/tsfmt/tsfmt.json new file mode 100644 index 0000000..334eceb --- /dev/null +++ b/test/fixture/specified-config/tsfmt/tsfmt.json @@ -0,0 +1,17 @@ +{ + "indentSize": 4, + "tabSize": 4, + "indentStyle": 2, + "newLineCharacter": "\r\n", + "convertTabsToSpaces": false, + "insertSpaceAfterCommaDelimiter": false, + "insertSpaceAfterSemicolonInForStatements": false, + "insertSpaceBeforeAndAfterBinaryOperators": false, + "insertSpaceAfterKeywordsInControlFlowStatements": false, + "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, + "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, + "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, + "placeOpenBraceOnNewLineForFunctions": false, + "placeOpenBraceOnNewLineForControlBlocks": false +} \ No newline at end of file diff --git a/test/fixture/specified-config/tslint/alt-tslint.json b/test/fixture/specified-config/tslint/alt-tslint.json new file mode 100644 index 0000000..b638669 --- /dev/null +++ b/test/fixture/specified-config/tslint/alt-tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "indent": [true, "tabs"] + } +} diff --git a/test/fixture/specified-config/tslint/main.ts b/test/fixture/specified-config/tslint/main.ts new file mode 100644 index 0000000..8ee345f --- /dev/null +++ b/test/fixture/specified-config/tslint/main.ts @@ -0,0 +1,6 @@ +class Sample { +hello(word:string="world"):string{return "Hello, " + word;} +} + +var s:Sample=new Sample(); +if(s===s){console.log(s.hello());} diff --git a/test/fixture/specified-config/tslint/tslint.json b/test/fixture/specified-config/tslint/tslint.json new file mode 100644 index 0000000..fd07766 --- /dev/null +++ b/test/fixture/specified-config/tslint/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "indent": [true, "spaces"] + } +} diff --git a/test/indexSpec.ts b/test/indexSpec.ts index d332c63..64f8646 100644 --- a/test/indexSpec.ts +++ b/test/indexSpec.ts @@ -99,7 +99,7 @@ describe("tsfmt test", () => { let ignoreList = [ "./test/fixture/editorconfig/space/main.ts", // TypeScript ignore indentSize: 8 "./test/fixture/tsfmt/a/main.ts", // TypeScript ignore indentSize: 1 - "./test/fixture/tslint/indent/main.ts" // TypeScript ignore indentSize: 6 + "./test/fixture/tslint/indent/main.ts", // TypeScript ignore indentSize: 6 ]; if (ignoreList.indexOf(fileName) !== -1) { it.skip(fileName, () => { @@ -107,6 +107,11 @@ describe("tsfmt test", () => { }); return; } + if (fileName.indexOf("./test/fixture/specified-config/") === 0) { + // uses later. + return; + } + it(fileName, () => { return lib .processFiles([fileName], { @@ -114,10 +119,13 @@ describe("tsfmt test", () => { replace: false, verify: false, tsconfig: true, + tsconfigFile: null, tslint: true, + tslintFile: null, editorconfig: true, vscode: true, - tsfmt: true + tsfmt: true, + tsfmtFile: null, }) .then(resultMap => { let result = resultMap[fileName]; @@ -169,10 +177,13 @@ describe("tsfmt test", () => { replace: false, verify: true, tsconfig: true, + tsconfigFile: null, tslint: true, + tslintFile: null, editorconfig: true, vscode: true, - tsfmt: true + tsfmt: true, + tsfmtFile: null, }) .then(resultMap => { assert(resultMap[fileName].error); @@ -193,10 +204,13 @@ describe("tsfmt test", () => { replace: false, verify: false, tsconfig: true, + tsconfigFile: null, tslint: true, + tslintFile: null, editorconfig: true, vscode: true, - tsfmt: true + tsfmt: true, + tsfmtFile: null, }) .then(result => { assert(result !== null); @@ -206,6 +220,80 @@ describe("tsfmt test", () => { }); }); + describe("use specified config", () => { + interface Matrix { + name: string; + settings: Partial; + targetFile: string; + } + const list: Matrix[] = [ + { + name: "tsconfig.json", + settings: { + tsconfigFile: "alt-tsconfig.json", + }, + targetFile: "./test/fixture/specified-config/tsconfig/main.ts", + }, + { + name: "tslint.json", + settings: { + tslintFile: "alt-tslint.json", + }, + targetFile: "./test/fixture/specified-config/tslint/main.ts", + }, + { + name: "tsfmt.json", + settings: { + tsfmtFile: "alt-tsfmt.json", + }, + targetFile: "./test/fixture/specified-config/tsfmt/main.ts", + }, + ]; + + list.forEach(matrix => { + it(`uses specified ${matrix.name} file`, () => { + return lib + .processFiles([matrix.targetFile], Object.assign({}, { + dryRun: true, + replace: false, + verify: false, + tsconfig: true, + tsconfigFile: null, + tslint: true, + tslintFile: null, + editorconfig: true, + vscode: true, + tsfmt: true, + tsfmtFile: null, + }, matrix.settings)) + .then(resultMap => { + let result = resultMap[matrix.targetFile]; + assert(result !== null); + assert(result.error === false); + + let expectedTsFileName = matrix.targetFile.replace(fixtureDir, expectedDir); + + if (!fs.existsSync(expectedTsFileName)) { + mkdirp.sync(path.dirname(expectedTsFileName)); + fs.writeFileSync(expectedTsFileName, result.dest); + } + + let expected = fs.readFileSync(expectedTsFileName, "utf-8"); + assert(expected === result.dest); + + let expectedSettingsFileName = expectedTsFileName.replace(/\.ts$/, ".json"); + + if (!fs.existsSync(expectedSettingsFileName)) { + fs.writeFileSync(expectedSettingsFileName, JSON.stringify(result.settings, null, 2)); + } + + let expectedSettings = lib.parseJSON(fs.readFileSync(expectedSettingsFileName, "utf-8")); + assert.deepEqual(expectedSettings, result.settings); + }); + }); + }); + }); + describe("CLI test", () => { it("should reformat files specified at files in tsconfig.json", () => { return exec(path.resolve("./bin/tsfmt"), [], { cwd: path.resolve('./test/cli/files') }).then(result => {