Skip to content

Commit

Permalink
fix(toolkit): fix broken confirmation prompt (aws#2333)
Browse files Browse the repository at this point in the history
We recently upgraded to a 'promptly' version whose methods
are already async, so no need to util.promisify it anymore.
In fact, the promise would never be resolved.
  • Loading branch information
rix0rrr authored and SanderKnape committed May 14, 2019
1 parent c6a2f9e commit 138e5ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'source-map-support/register';

import colors = require('colors/safe');
import fs = require('fs-extra');
import util = require('util');
import yargs = require('yargs');

import { bootstrapEnvironment, destroyStack, SDK } from '../lib';
Expand All @@ -25,7 +24,6 @@ import { VERSION } from '../lib/version';

// tslint:disable-next-line:no-var-requires
const promptly = require('promptly');
const confirm = util.promisify(promptly.confirm);

// tslint:disable:no-shadowed-variable max-line-length
async function parseCommandLineArguments() {
Expand Down Expand Up @@ -359,7 +357,7 @@ async function initCommandLine() {

if (!force) {
// tslint:disable-next-line:max-line-length
const confirmed = await confirm(`Are you sure you want to delete: ${colors.blue(stacks.map(s => s.name).join(', '))} (y/n)?`);
const confirmed = await promptly.confirm(`Are you sure you want to delete: ${colors.blue(stacks.map(s => s.name).join(', '))} (y/n)?`);
if (!confirmed) {
return;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import colors = require('colors/safe');
import fs = require('fs-extra');
import { format, promisify } from 'util';
import { format } from 'util';
import { AppStacks, ExtendedStackSelection } from "./api/cxapp/stacks";
import { IDeploymentTarget } from './api/deployment-target';
import { printSecurityDiff, printStackDiff, RequireApproval } from './diff';
Expand All @@ -9,7 +9,6 @@ import { deserializeStructure } from './serialize';

// tslint:disable-next-line:no-var-requires
const promptly = require('promptly');
const confirm = promisify(promptly.confirm);

export interface CdkToolkitProps {
/**
Expand Down Expand Up @@ -98,7 +97,7 @@ export class CdkToolkit {
'but terminal (TTY) is not attached so we are unable to get a confirmation from the user');
}

const confirmed = await confirm(`Do you wish to deploy these changes (y/n)?`);
const confirmed = await promptly.confirm(`Do you wish to deploy these changes (y/n)?`);
if (!confirmed) { throw new Error('Aborted by user'); }
}
}
Expand Down Expand Up @@ -230,4 +229,4 @@ export interface DeployOptions {
* Reuse the assets with the given asset IDs
*/
reuseAssets?: string[];
}
}

0 comments on commit 138e5ea

Please sign in to comment.