Skip to content
Snippets Groups Projects
Unverified Commit 1d29b462 authored by David Sehnal's avatar David Sehnal Committed by GitHub
Browse files

Merge pull request #305 from MadCatX/cleanup-old-nodejs

Make cleanup script work with older vesions of Node.js
parents 06b4761f bd44c767
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,23 @@ ...@@ -7,6 +7,23 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
function removeDir(dirPath) {
for (const ent of fs.readdirSync(dirPath)) {
const entryPath = path.join(dirPath, ent);
remove(entryPath);
}
fs.rmdirSync(dirPath);
}
function remove(entryPath) {
const st = fs.statSync(entryPath);
if (st.isDirectory())
removeDir(entryPath);
else
fs.unlinkSync(entryPath);
}
const toClean = [ const toClean = [
path.resolve(__dirname, '../build'), path.resolve(__dirname, '../build'),
path.resolve(__dirname, '../lib'), path.resolve(__dirname, '../lib'),
...@@ -14,6 +31,11 @@ const toClean = [ ...@@ -14,6 +31,11 @@ const toClean = [
]; ];
toClean.forEach(ph => { toClean.forEach(ph => {
if (fs.existsSync(ph)) if (fs.existsSync(ph)) {
fs.rm(ph, { recursive: true }, err => { if (err) console.warn(`Failed to delete ${ph}: ${err}`); }); try {
remove(ph);
} catch (err) {
console.warn(`Cleanup failed: ${err}`);
}
}
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment