Skip to content

Commit 1ad2590

Browse files
committed
fix(tsfmt): use --useTsconfig value to use when creating target files list fixes #90
1 parent 5edfef9 commit 1ad2590

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

lib/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ let root = commandpost
7777
let files = args.files;
7878
let useTsconfig = false;
7979
if (files.length === 0) {
80-
let configFileName = getConfigFileName(baseDir || process.cwd(), "tsconfig.json");
80+
let configFileName = tsconfigFile || getConfigFileName(baseDir || process.cwd(), "tsconfig.json");
8181
if (configFileName) {
8282
files = readFilesFromTsconfig(configFileName);
8383
if (verbose) {

test/cli/useTsconfig/exclude.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export class Sample {hello(){console.log("Hello world");}}
2+
new Sample().hello();

test/cli/useTsconfig/include.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export class Sample {hello(){console.log("Hello world");}}
2+
new Sample().hello();
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es5",
5+
"noImplicitAny": false,
6+
"sourceMap": false
7+
},
8+
"files": [
9+
"include.ts"
10+
]
11+
}

test/indexSpec.ts

+10
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,16 @@ export class TestCLI {
314314
method() {
315315
}
316316
}
317+
`.trim().replace(/\n/g, "\r\n"));
318+
});
319+
});
320+
321+
it("should pickup files from --useTsconfig specified tsconfig.json", () => {
322+
return exec(path.resolve("./bin/tsfmt"), ["--verify", "--useTsconfig", "./tsconfig.main.json"], { cwd: path.resolve('./test/cli/useTsconfig') }).then(result => {
323+
assert.equal(result.status, 1);
324+
assert.equal(result.stdout.trim(), "");
325+
assert.equal(result.stderr.replace(process.cwd(), "**").trim(), `
326+
**/test/cli/useTsconfig/include.ts is not formatted
317327
`.trim().replace(/\n/g, "\r\n"));
318328
});
319329
});

0 commit comments

Comments
 (0)