Skip to content

Commit

Permalink
fix(lint): Only default to src test if they exist (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-kvale-sap authored and jaredpalmer committed Dec 3, 2019
1 parent a1a0dcb commit 3261dea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,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"'
)
);
}
Expand Down
5 changes: 4 additions & 1 deletion test/tests/lint/tsdx-lint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 3261dea

Please sign in to comment.