diff --git a/lib/file.js b/lib/file.js index 7df6696..49448b0 100644 --- a/lib/file.js +++ b/lib/file.js @@ -37,3 +37,7 @@ export function readJson(file) { } return {}; }; + +export function removeDirectory(directory) { + return fs.promises.rm(directory, { recursive: true, force: true }); +} diff --git a/lib/wpt/index.js b/lib/wpt/index.js index 52d2376..601b207 100644 --- a/lib/wpt/index.js +++ b/lib/wpt/index.js @@ -3,7 +3,9 @@ import path from 'node:path'; import _ from 'lodash'; import GitHubTree from '../github/tree.js'; -import { writeFile, readJson, writeJson, readFile } from '../file.js'; +import { + writeFile, readJson, writeJson, readFile, removeDirectory +} from '../file.js'; import { shortSha } from '../utils.js'; @@ -73,6 +75,9 @@ export class WPTUpdater { assets = await this.getAssetList(); } + this.cli.startSpinner('Removing stale assets...'); + await removeDirectory(this.fixtures(this.path)); + this.cli.startSpinner('Pulling assets...'); await Promise.all(assets.map( (asset) => this.pullTextFile(fixtures, asset.name)