From 4962bb5a4b324959deb2cbe3b1076679a708ea8e Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Sat, 9 Dec 2023 01:25:46 +0200 Subject: [PATCH] feat(dev-env): add quiet mode for "import sql" --- src/bin/vip-dev-env-import-sql.js | 1 + src/commands/dev-env-import-sql.js | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bin/vip-dev-env-import-sql.js b/src/bin/vip-dev-env-import-sql.js index 52f11ae0aa..1a56183f9a 100755 --- a/src/bin/vip-dev-env-import-sql.js +++ b/src/bin/vip-dev-env-import-sql.js @@ -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; diff --git a/src/commands/dev-env-import-sql.js b/src/commands/dev-env-import-sql.js index 32957ef36f..3f4cc53e68 100644 --- a/src/commands/dev-env-import-sql.js +++ b/src/commands/dev-env-import-sql.js @@ -90,7 +90,7 @@ export class DevEnvImportSQLCommand { process.stdin.isTTY = origIsTTY; } - if ( searchReplace && searchReplace.length && ! inPlace ) { + if ( searchReplace?.length && ! inPlace ) { fs.unlinkSync( resolvedPath ); } @@ -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',