Skip to content

Commit

Permalink
fix(toolkit): ignore hidden files for 'cdk init' (#1766)
Browse files Browse the repository at this point in the history
Don't block 'cdk init' on the presence of files start with '.'.

In particular, don't care about the presence of a '.git' directory.

Fixes #1758.
  • Loading branch information
rix0rrr authored Feb 14, 2019
1 parent c87f09a commit afdd173
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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);

// 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();
}
};

0 comments on commit afdd173

Please sign in to comment.