Skip to content

Commit

Permalink
Merge pull request #78 from hashicorp/cdktf-synth-outdir
Browse files Browse the repository at this point in the history
Set precedent for CLI output directory argument
  • Loading branch information
joatmon08 authored May 12, 2020
2 parents 3f4e440 + 4160bc9 commit 6498c0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.0.4

- Getting started guide for Python (#73)
- Change output directory to `cdktf.out` for Terraform configuration (#70)
- Fix output directory argument for `cdktf synth` (#62)

## 0.0.3

Enable synthesis to Python
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "root",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"scripts": {
"build": "lerna run build",
Expand Down
12 changes: 12 additions & 0 deletions packages/cdktf-cli/bin/cmds/synth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ class Command implements yargs.CommandModule {
const command = argv.app;
const outdir = argv.output;

if (!await fs.pathExists(config.output)) {
console.error(`ERROR: synthesis failed, run "cdktf get" to generate providers in ${config.output}`);
process.exit(1);
}

if (config.output != outdir) {
if (!fs.copy(config.output, outdir)) {
console.error(`ERROR: synthesis failed, could not copy providers from ${config.output}`);
process.exit(1);
}
}

await shell(command, [], {
shell: true,
env: {
Expand Down
2 changes: 1 addition & 1 deletion packages/cdktf/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class App extends Construct {
*/
constructor(options: AppOptions = {}) {
super(undefined as any, '');
this.outdir = options.outdir ?? process.env.CDKTF_OUTDIR ?? 'cdktf.out';
this.outdir = process.env.CDKTF_OUTDIR ?? options.outdir ?? 'cdktf.out';
}

/**
Expand Down

0 comments on commit 6498c0f

Please sign in to comment.