-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
edenhliu
committed
May 21, 2019
1 parent
324811f
commit 6e71140
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { logWithSpinner, stopSpinner } from '@a8k/cli-utils/spinner'; | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
async function cleanUnusedCache(context) { | ||
const { cacheBase, cache } = context.config; | ||
if (cacheBase) { | ||
logWithSpinner('clean old cache'); | ||
const list = await fs.readdir(cacheBase); | ||
await Promise.all( | ||
list | ||
.filter(i => path.basename(cache) !== i) | ||
.map(i => path.join(cacheBase, i)) | ||
.map(filepath => fs.remove(filepath)) | ||
); | ||
stopSpinner(); | ||
} | ||
} | ||
export default cleanUnusedCache; |