From 85af4a0de34325bfeb661db1bb72d6000269a9e1 Mon Sep 17 00:00:00 2001 From: Sam Kvale Date: Thu, 21 Nov 2019 20:47:34 -0600 Subject: [PATCH] fix(lint): Only default to src test if they exist --- src/index.ts | 5 +++-- test/tests/lint/tsdx-lint.test.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index e0c28827e..081c3483f 100755 --- a/src/index.ts +++ b/src/index.ts @@ -494,11 +494,12 @@ prog _: string[]; }) => { if (opts['_'].length === 0 && !opts['write-file']) { - const defaultInputs = ['src', 'test']; + const defaultInputs = ['src', 'test'].filter(fs.existsSync); opts['_'] = defaultInputs; console.log( chalk.yellow( - `No input files specified, defaulting to ${defaultInputs.join(' ')}` + `Defaulting to "tsdx lint ${defaultInputs.join(' ')}"`, + '\nYou can override this in the package.json scripts, like "lint": "tsdx lint src otherDir"' ) ); } diff --git a/test/tests/lint/tsdx-lint.test.js b/test/tests/lint/tsdx-lint.test.js index cd2f6fd26..c1de43d92 100644 --- a/test/tests/lint/tsdx-lint.test.js +++ b/test/tests/lint/tsdx-lint.test.js @@ -47,7 +47,10 @@ describe('tsdx lint', () => { it('should not lint', () => { const output = shell.exec(`node dist/index.js lint`); expect(output.code).toBe(1); - expect(output.toString()).toContain('No input files specified, defaulting to src test'); + expect(output.toString()).toContain('Defaulting to "tsdx lint src test"'); + expect(output.toString()).toContain( + 'You can override this in the package.json scripts, like "lint": "tsdx lint src otherDir"' + ); }); describe('when --write-file is used', () => {