@@ -5,6 +5,7 @@ import path from 'node:path';
55import { confirm } from '@inquirer/prompts' ;
66import { getConfigDirectory } from '@studio/common/lib/well-known-paths' ;
77import { __ , sprintf } from '@wordpress/i18n' ;
8+ import trash from 'trash' ;
89import { Mode , runCommand as stopSites } from 'cli/commands/site/stop' ;
910import { getCliInstallKind } from 'cli/lib/update-notifier' ;
1011import { StudioArgv } from 'cli/types' ;
@@ -73,6 +74,7 @@ export async function runCommand( purge: boolean ): Promise< void > {
7374 console . log (
7475 __ ( 'This Studio CLI was installed via npm. Remove it with: npm rm -g wp-studio' )
7576 ) ;
77+ process . exitCode = 1 ;
7678 return ;
7779 }
7880 if ( installKind !== 'standalone' ) {
@@ -81,6 +83,7 @@ export async function runCommand( purge: boolean ): Promise< void > {
8183 'This Studio CLI is bundled with the Studio desktop app. Uninstall the app to remove it.'
8284 )
8385 ) ;
86+ process . exitCode = 1 ;
8487 return ;
8588 }
8689
@@ -100,7 +103,7 @@ export async function runCommand( purge: boolean ): Promise< void > {
100103 removeConfig = await confirm ( {
101104 message : sprintf (
102105 /* translators: %s is the config directory path */
103- __ ( 'Permanently delete your Studio config and site list in %s?' ) ,
106+ __ ( 'Delete your Studio config in %s?' ) ,
104107 configDir
105108 ) ,
106109 default : false ,
@@ -125,7 +128,9 @@ export async function runCommand( purge: boolean ): Promise< void > {
125128 }
126129
127130 if ( removeConfig ) {
128- fs . rmSync ( configDir , { recursive : true , force : true } ) ;
131+ // Trash rather than hard-delete — the user's sites/config are recoverable if they
132+ // change their mind.
133+ await trash ( configDir ) ;
129134 removed . push ( configDir ) ;
130135 }
131136
@@ -137,7 +142,7 @@ export async function runCommand( purge: boolean ): Promise< void > {
137142 console . log (
138143 sprintf (
139144 /* translators: %s is the config directory path */
140- __ ( '\nYour sites and config were kept in %s. Re-run with --purge to remove them .' ) ,
145+ __ ( '\nYour Studio config and sites are still in %s.' ) ,
141146 configDir
142147 )
143148 ) ;
@@ -159,7 +164,7 @@ export const registerCommand = ( yargs: StudioArgv ) => {
159164 return yargs . option ( 'purge' , {
160165 type : 'boolean' ,
161166 alias : 'all' ,
162- describe : __ ( 'Also delete your Studio config and site list (~/.studio)' ) ,
167+ describe : __ ( 'Also delete your Studio config (~/.studio)' ) ,
163168 default : false ,
164169 } ) ;
165170 } ,
0 commit comments