Skip to content

Commit

Permalink
feat(dev-env): add quiet mode for "import sql"
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Dec 8, 2023
1 parent 504f419 commit 4962bb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/bin/vip-dev-env-import-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ command( {
.option( [ 'r', 'search-replace' ], 'Perform Search and Replace on the specified SQL file' )
.option( 'in-place', 'Search and Replace explicitly on the given input file' )
.option( 'skip-validate', 'Do not perform file validation.' )
.option( 'quiet', 'Suppress prompts.' )
.examples( examples )
.argv( process.argv, async ( unmatchedArgs, opt ) => {
const [ fileName ] = unmatchedArgs;
Expand Down
13 changes: 8 additions & 5 deletions src/commands/dev-env-import-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class DevEnvImportSQLCommand {
process.stdin.isTTY = origIsTTY;
}

if ( searchReplace && searchReplace.length && ! inPlace ) {
if ( searchReplace?.length && ! inPlace ) {
fs.unlinkSync( resolvedPath );
}

Expand All @@ -99,10 +99,13 @@ export class DevEnvImportSQLCommand {

try {
await exec( lando, this.slug, [ 'wp', 'cli', 'has-command', 'vip-search' ] );
const doIndex = await promptForBoolean(
'Do you want to index data in Elasticsearch (used by Enterprise Search)?',
true
);
const doIndex =
this.options.quiet || ! process.stdin.isTTY
? true
: await promptForBoolean(
'Do you want to index data in Elasticsearch (used by Enterprise Search)?',
true
);
if ( doIndex ) {
await exec( lando, this.slug, [
'wp',
Expand Down

0 comments on commit 4962bb5

Please sign in to comment.