Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lint): Only default to src test if they exist #344

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
)
);
}
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