/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/env/lib/commands/destroy.js
69 строк
2 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
'use strict'; const fs = require( 'fs' ).promises; const path = require( 'path' ); const { confirm } = require( '@inquirer/prompts' ); const { loadConfig } = require( '../config' ); const { executeLifecycleScript } = require( '../execute-lifecycle-script' ); const { getRuntime, detectRuntime } = require( '../runtime' ); /** * Destroy the development server. * * @param {Object} options * @param {Object} options.spinner A CLI spinner which indicates progress. * @param {boolean} options.scripts Indicates whether or not lifecycle scripts should be executed. * @param {boolean} options.force If true, skips the confirmation prompt. * @param {boolean} options.debug True if debug mode is enabled. * @param {string|null} options.config Path to a custom .wp-env.json configuration file. */ module.exports = async function destroy( { spinner, scripts, force, debug, config: customConfigPath, } ) { const config = await loadConfig( path.resolve( '.' ), customConfigPath ); try { await fs.readdir( config.workDirectoryPath ); } catch { spinner.text = 'Could not find any files to remove.'; return; } const runtime = getRuntime( await detectRuntime( config.workDirectoryPath ) ); spinner.info( runtime.getDestroyWarningMessage() ); let yesDelete = force; if ( ! force ) { try { yesDelete = await confirm( { message: 'Are you sure you want to continue?', default: false, } ); } catch ( error ) { if ( error.name === 'ExitPromptError' ) { console.log( 'Cancelled.' ); process.exit( 1 ); } throw error; } } spinner.start(); if ( ! yesDelete ) { spinner.text = 'Cancelled.'; return; } await runtime.destroy( config, { spinner, debug } ); if ( scripts ) { await executeLifecycleScript( 'afterDestroy', config, spinner ); } };