Skip to content

Instantly share code, notes, and snippets.

@revanth0212
Created August 10, 2021 22:30
Show Gist options
  • Save revanth0212/ebc634435eb37bc3e68f1af543f42da9 to your computer and use it in GitHub Desktop.
Save revanth0212/ebc634435eb37bc3e68f1af543f42da9 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);
});
@revanth0212
Copy link
Author

To run

node pwaCacheClean.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment