Skip to content

Instantly share code, notes, and snippets.

@larsroettig
Forked from revanth0212/pwaCacheClean.js
Created August 18, 2021 09:11
Show Gist options
  • Save larsroettig/647e1dcdd6629ddaf990cddafb5f63e7 to your computer and use it in GitHub Desktop.
Save larsroettig/647e1dcdd6629ddaf990cddafb5f63e7 to your computer and use it in GitHub Desktop.
While using PWA Studio's scaffolding command if you run into any errors or if you notice the command using old packages, run this file to clear your cache and try again.
const fs = require("fs");
const os = require("os");
const { promisify } = require("util");
const exec = promisify(require("child_process").exec);
const temptdir = os.tmpdir();
if (fs.existsSync(`${temptdir}/@magento`)) {
fs.rmdirSync(`${temptdir}/@magento`, { recursive: true });
console.log("Done cleaning node cache");
} else {
console.log("No cached node packages to clear");
}
exec("yarn cache clean")
.then(() => {
console.log("Done cleaning yarn cache");
})
.catch((err) => {
console.log("No cached yarn packages to clear");
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment