Skip to content

Commit

Permalink
Do same for delete
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum committed Aug 7, 2024
1 parent 4304c87 commit f321722
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/bin/vip-config-envvar-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import chalk from 'chalk';

import command from '../lib/cli/command';
import { formatEnvironment } from '../lib/cli/format';
import { appQuery, deleteEnvVar, validateNameWithMessage } from '../lib/envvar/api';
import { cancel, confirm, promptForValue } from '../lib/envvar/input';
import { debug, getEnvContext } from '../lib/envvar/logging';
Expand Down Expand Up @@ -37,6 +38,24 @@ export async function deleteEnvVarCommand( arg, opt ) {
variable_name: name,
};

const envName = opt.env.type;
const appName = opt.app.name;

if ( ! opt.skipConfirmation && envName === 'production' ) {
const yes = await confirm(
`Are you sure you want to delete the environment variable ${ name } on ${ formatEnvironment(
envName
) } for site ${ appName }?`
);

if ( ! yes ) {
trackEvent( 'wpcli_confirm_cancel', trackingParams ).catch( () => {} );

console.log( 'Command cancelled' );
process.exit();
}
}

debug(
`Request: Delete environment variable ${ JSON.stringify( name ) } for ${ getEnvContext(
opt.app,
Expand Down

0 comments on commit f321722

Please sign in to comment.