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(toolkit): ignore hidden files for 'cdk init' #1766

Merged
merged 2 commits into from
Feb 14, 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
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ async function initializeProject(template: InitTemplate, language: string, canUs

async function assertIsEmptyDirectory() {
const files = await fs.readdir(process.cwd());
if (files.length !== 0) {
if (files.filter(f => !f.startsWith('.')).length !== 0) {
throw new Error('`cdk init` cannot be run in a non-empty directory!');
}
}
Expand Down
12 changes: 12 additions & 0 deletions packages/aws-cdk/test/test.init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ export = {
test.equal(true, await fs.pathExists('package.json'));
test.equal(true, await fs.pathExists('bin'));

test.done();
},

async 'git directory does not throw off the initer!'(test: Test) {
fs.mkdirSync('.git');

await cliInit('app', 'typescript', false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this run npm install during the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it does not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come?


// Check that package.json and bin/ got created in the current directory
test.equal(true, await fs.pathExists('package.json'));
test.equal(true, await fs.pathExists('bin'));

test.done();
}
};