Skip to content

Commit b33507d

Browse files
committed
feat(clean): allow overriding pathsToClean in config
1 parent 3063550 commit b33507d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

lib/commands/clean.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,26 @@ export class CleanCommand implements ICommand {
1919
const spinner = this.$terminalSpinnerService.createSpinner();
2020
spinner.start("Cleaning project...\n");
2121

22-
const pathsToClean = [
22+
let pathsToClean = [
2323
constants.HOOKS_DIR_NAME,
2424
constants.PLATFORMS_DIR_NAME,
2525
constants.NODE_MODULES_FOLDER_NAME,
2626
constants.PACKAGE_LOCK_JSON_FILE_NAME,
2727
];
2828

2929
try {
30+
const overridePathsToClean = this.$projectConfigService.getValue(
31+
"cli.pathsToClean"
32+
);
3033
const additionalPaths = this.$projectConfigService.getValue(
3134
"cli.additionalPathsToClean"
3235
);
36+
37+
// allow overriding default paths to clean
38+
if (Array.isArray(overridePathsToClean)) {
39+
pathsToClean = overridePathsToClean;
40+
}
41+
3342
if (Array.isArray(additionalPaths)) {
3443
pathsToClean.push(...additionalPaths);
3544
}

lib/services/project-cleanup-service.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ export class ProjectCleanupService implements IProjectCleanupService {
1111
private $logger: ILogger,
1212
private $projectHelper: IProjectHelper,
1313
private $terminalSpinnerService: ITerminalSpinnerService
14-
) {
15-
this.spinner = this.$terminalSpinnerService.createSpinner();
16-
}
14+
) {}
1715

1816
public async clean(pathsToClean: string[]): Promise<boolean> {
17+
this.spinner = this.$terminalSpinnerService.createSpinner();
1918
let success = true;
2019
for (const pathToClean of pathsToClean) {
2120
const isCleaned = await this.cleanPath(pathToClean).catch((error) => {
@@ -27,13 +26,17 @@ export class ProjectCleanupService implements IProjectCleanupService {
2726
});
2827
success = success && isCleaned;
2928
}
29+
30+
// required to print an empty line for the spinner to not replace the last status... (probably a bug in the spinners)
31+
console.log();
3032
return success;
3133
}
3234

3335
public async cleanPath(pathToClean: string): Promise<boolean> {
3436
this.spinner.clear();
3537
let success = true;
3638
let fileType: string;
39+
3740
if (!pathToClean || pathToClean.trim().length === 0) {
3841
this.$logger.trace("cleanPath called with no pathToClean.");
3942
return success;
@@ -70,8 +73,8 @@ export class ProjectCleanupService implements IProjectCleanupService {
7073
return success;
7174
}
7275
this.$logger.trace(`Path '${filePath}' not found, skipping.`);
73-
// this.spinner.text = `Skipping ${displayPath} because it doesn't exist.`;
74-
// this.spinner.info();
76+
this.spinner.info(`Skipping ${displayPath} because it doesn't exist.`);
77+
7578
return success;
7679
}
7780
}

0 commit comments

Comments
 (0)