Skip to content

Commit 1c8f911

Browse files
committed
refactor: Adapt clean to modern logs
1 parent e3afe7b commit 1c8f911

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

lib/clean.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ function cleanup() {
3838
function cleanupCache() {
3939
const cacheLocation = getUserCachePath(this.options);
4040
if (fse.existsSync(cacheLocation)) {
41+
let cleanupProgress;
4142
if (this.serverless) {
42-
this.serverless.cli.log(`Removing static caches at: ${cacheLocation}`);
43+
if (this.progress) {
44+
cleanupProgress = this.progress.get('python-cleanup-cache');
45+
cleanupProgress.notice(`Removing static caches at: ${cacheLocation}`, {
46+
isMainEvent: true,
47+
});
48+
} else {
49+
this.serverless.cli.log(`Removing static caches at: ${cacheLocation}`);
50+
}
4351
}
4452

4553
// Only remove cache folders that we added, just incase someone accidentally puts a weird
@@ -50,10 +58,19 @@ function cleanupCache() {
5058
.forEach((file) => {
5159
promises.push(fse.removeAsync(file));
5260
});
53-
return BbPromise.all(promises);
61+
return BbPromise.all(promises)
62+
.then(() => cleanupProgress && cleanupProgress.remove())
63+
.catch((e) => {
64+
cleanupProgress && cleanupProgress.remove();
65+
throw e;
66+
});
5467
} else {
5568
if (this.serverless) {
56-
this.serverless.cli.log(`No static cache found`);
69+
if (this.log) {
70+
this.log.info(`No static cache found`);
71+
} else {
72+
this.serverless.cli.log(`No static cache found`);
73+
}
5774
}
5875
return BbPromise.resolve();
5976
}

0 commit comments

Comments
 (0)