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

refactor(core): rename "Stack.autoRun" to "autoSynth" #3016

Merged
merged 2 commits into from
Jun 23, 2019
Merged
Changes from 1 commit
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
15 changes: 9 additions & 6 deletions packages/@aws-cdk/cdk/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ const APP_SYMBOL = Symbol.for('@aws-cdk/cdk.App');
*/
export interface AppProps {
/**
* Automatically call run before the application exits
* Automatically call `synth()` before the program exits.
*
* If you set this, you don't have to call `synth()` anymore.
* If you set this, you don't have to call `synth()` explicitly. Note that
* this feature is only available for certain programming languages, and
Copy link
Contributor

Choose a reason for hiding this comment

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

which languages are supported / which ones are not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not 100% sure TBH. I think some jsii languages don't implement the exit hook properly and I wanted to set expectations that this is not 100% working... We need to fix it obvsiouly and then remove this warning.

* calling `synth()` is still recommended.
*
* @default true if running via CDK toolkit (`CDK_OUTDIR` is set), false otherwise
* @default true if running via CDK CLI (`CDK_OUTDIR` is set), `false`
* otherwise
*/
readonly autoRun?: boolean;
readonly autoSynth?: boolean;

/**
* The output directory into which to emit synthesized artifacts.
Expand Down Expand Up @@ -101,8 +104,8 @@ export class App extends Construct {
this.runtimeInfo = this.node.tryGetContext(cxapi.DISABLE_VERSION_REPORTING) ? false : true;
this.outdir = props.outdir || process.env[cxapi.OUTDIR_ENV];

const autoRun = props.autoRun !== undefined ? props.autoRun : cxapi.OUTDIR_ENV in process.env;
if (autoRun) {
const autoSynth = props.autoSynth !== undefined ? props.autoSynth : cxapi.OUTDIR_ENV in process.env;
if (autoSynth) {
// synth() guarantuees it will only execute once, so a default of 'true'
// doesn't bite manual calling of the function.
process.once('beforeExit', () => this.synth());
Expand Down