-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(aws-cdk): report and continue on git errors (#587)
Don't stop the 'cdk init' process if there's a problem with 'git init/add/commit'. Instead, report an error and continue. This makes sure 'cdk init' doesn't break for people with custom git setups. Fixes #530.
- Loading branch information
Showing
2 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import fs = require('fs-extra'); | ||
import { Test } from 'nodeunit'; | ||
import os = require('os'); | ||
import path = require('path'); | ||
import { cliInit } from '../lib/init'; | ||
|
||
const state: { | ||
previousWorkingDir?: string; | ||
tempDir?: string; | ||
} = {}; | ||
|
||
export = { | ||
async "setUp"(callback: () => void) { | ||
state.previousWorkingDir = process.cwd(); | ||
state.tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'aws-cdk-test')); | ||
// tslint:disable-next-line:no-console | ||
console.log('Temporary working directory:', state.tempDir); | ||
process.chdir(state.tempDir); | ||
callback(); | ||
}, | ||
|
||
async "tearDown"(callback: () => void) { | ||
// tslint:disable-next-line:no-console | ||
console.log('Switching back to', state.previousWorkingDir, 'cleaning up', state.tempDir); | ||
process.chdir(state.previousWorkingDir!); | ||
await fs.remove(state.tempDir!); | ||
|
||
callback(); | ||
}, | ||
|
||
async 'create a TypeScript library project'(test: Test) { | ||
await cliInit('lib', 'typescript', false); | ||
|
||
// Check that package.json and lib/ got created in the current directory | ||
test.equal(true, await fs.pathExists('package.json')); | ||
test.equal(true, await fs.pathExists('lib')); | ||
|
||
test.done(); | ||
}, | ||
|
||
async 'create a TypeScript app project'(test: Test) { | ||
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(); | ||
} | ||
}; |