1
+ import { color } from "../color" ;
1
2
import { ICommand , ICommandParameter } from "../common/definitions/commands" ;
2
3
import { injector } from "../common/yok" ;
3
4
import * as constants from "../constants" ;
@@ -114,9 +115,8 @@ export class CleanCommand implements ICommand {
114
115
] ;
115
116
116
117
try {
117
- const overridePathsToClean = this . $projectConfigService . getValue (
118
- "cli.pathsToClean"
119
- ) ;
118
+ const overridePathsToClean =
119
+ this . $projectConfigService . getValue ( "cli.pathsToClean" ) ;
120
120
const additionalPaths = this . $projectConfigService . getValue (
121
121
"cli.additionalPathsToClean"
122
122
) ;
@@ -158,7 +158,7 @@ export class CleanCommand implements ICommand {
158
158
if ( res . ok ) {
159
159
spinner . succeed ( "Project successfully cleaned." ) ;
160
160
} else {
161
- spinner . fail ( ` ${ "Project unsuccessfully cleaned." . red } ` ) ;
161
+ spinner . fail ( color . red ( "Project unsuccessfully cleaned." ) ) ;
162
162
}
163
163
}
164
164
@@ -183,7 +183,7 @@ export class CleanCommand implements ICommand {
183
183
184
184
let computed = 0 ;
185
185
const updateProgress = ( ) => {
186
- const current = `${ computed } /${ paths . length } ` . grey ;
186
+ const current = color . grey ( `${ computed } /${ paths . length } ` ) ;
187
187
spinner . start (
188
188
`Gathering cleanable sizes. This may take a while... ${ current } `
189
189
) ;
@@ -236,9 +236,11 @@ export class CleanCommand implements ICommand {
236
236
. reduce ( ( a , b ) => a + b , 0 ) ;
237
237
238
238
const pathsToClean = await this . $prompter . promptForChoice (
239
- `Found ${ projects . size } cleanable project(s) with a total size of: ${
240
- bytesToHumanReadable ( totalSize ) . green
241
- } . Select projects to clean`,
239
+ `Found ${
240
+ projects . size
241
+ } cleanable project(s) with a total size of: ${ color . green (
242
+ bytesToHumanReadable ( totalSize )
243
+ ) } . Select projects to clean`,
242
244
Array . from ( projects . keys ( ) ) . map ( ( p ) => {
243
245
const size = projects . get ( p ) ;
244
246
let description ;
@@ -249,7 +251,7 @@ export class CleanCommand implements ICommand {
249
251
}
250
252
251
253
return {
252
- title : `${ p } ${ description . grey } ` ,
254
+ title : `${ p } ${ color . grey ( description ) } ` ,
253
255
value : p ,
254
256
} ;
255
257
} ) ,
@@ -261,9 +263,11 @@ export class CleanCommand implements ICommand {
261
263
this . $logger . clearScreen ( ) ;
262
264
263
265
spinner . warn (
264
- `This will run "${ `ns clean` . yellow } " in all the selected projects and ${
265
- "delete files from your system" . red . bold
266
- } !`
266
+ `This will run "${ color . yellow (
267
+ `ns clean`
268
+ ) } " in all the selected projects and ${ color . red . bold (
269
+ "delete files from your system"
270
+ ) } !`
267
271
) ;
268
272
spinner . warn ( `This action cannot be undone!` ) ;
269
273
@@ -281,7 +285,7 @@ export class CleanCommand implements ICommand {
281
285
const currentPath = pathsToClean [ i ] ;
282
286
283
287
spinner . start (
284
- `Cleaning ${ currentPath . cyan } ... ${ i + 1 } /${ pathsToClean . length } `
288
+ `Cleaning ${ color . cyan ( currentPath ) } ... ${ i + 1 } /${ pathsToClean . length } `
285
289
) ;
286
290
287
291
const ok = await this . $childProcess
@@ -304,19 +308,21 @@ export class CleanCommand implements ICommand {
304
308
305
309
if ( ok ) {
306
310
const cleanedSize = projects . get ( currentPath ) ;
307
- const cleanedSizeStr = `- ${ bytesToHumanReadable ( cleanedSize ) } ` . grey ;
308
- spinner . succeed ( `Cleaned ${ currentPath . cyan } ${ cleanedSizeStr } ` ) ;
311
+ const cleanedSizeStr = color . grey (
312
+ `- ${ bytesToHumanReadable ( cleanedSize ) } `
313
+ ) ;
314
+ spinner . succeed ( `Cleaned ${ color . cyan ( currentPath ) } ${ cleanedSizeStr } ` ) ;
309
315
totalSizeCleaned += cleanedSize ;
310
316
} else {
311
- spinner . fail ( `Failed to clean ${ currentPath . cyan } - skipped` ) ;
317
+ spinner . fail ( `Failed to clean ${ color . cyan ( currentPath ) } - skipped` ) ;
312
318
}
313
319
}
314
320
spinner . clear ( ) ;
315
321
spinner . stop ( ) ;
316
322
spinner . succeed (
317
- `Done! We've just freed up ${
318
- bytesToHumanReadable ( totalSizeCleaned ) . green
319
- } ! Woohoo! 🎉`
323
+ `Done! We've just freed up ${ color . green (
324
+ bytesToHumanReadable ( totalSizeCleaned )
325
+ ) } ! Woohoo! 🎉`
320
326
) ;
321
327
322
328
if ( this . $options . dryRun ) {
0 commit comments