diff --git a/dev/clean.js b/dev/clean.js new file mode 100644 index 000000000..224e09d75 --- /dev/null +++ b/dev/clean.js @@ -0,0 +1,39 @@ +'use strict'; + +// Define some pseudo module globals +var isPro = require('../libs/debug').isPro; +var isDev = require('../libs/debug').isDev; +var isDbg = require('../libs/debug').isDbg; + +// +// NOTE: Only use native *node* `require`s in this file +// since dependencies may not be installed yet +// +var fs = require('fs'); + +var rmFilesExceptHidden = function (dirPath) { + var files = null; + var filePath = null; + var i = null; + + try { + files = fs.readdirSync(dirPath); + } catch (aE) { + console.warn(dirPath, 'path not found'); + return; + } + + if (files.length > 0) { + for (i = 0; i < files.length; i++) { + filePath = dirPath + '/' + files[i]; + if (fs.statSync(filePath).isFile() && files[i].indexOf('.') !== 0) { + fs.unlinkSync(filePath); + } + } + } +}; + +console.log('Attempting to clean caches'); +rmFilesExceptHidden('./dev/cache/express-minify/release/'); + + diff --git a/dev/postinit.js b/dev/postinstall.js similarity index 100% rename from dev/postinit.js rename to dev/postinstall.js diff --git a/dev/preinit.js b/dev/preinstall.js similarity index 90% rename from dev/preinit.js rename to dev/preinstall.js index 0aac40f29..2f73abefd 100644 --- a/dev/preinit.js +++ b/dev/preinstall.js @@ -15,5 +15,5 @@ console.log('Attempting to delete `package-lock.json`'); try { fs.unlinkSync('./package-lock.json'); } catch (aE) { - console.log('Nothing to delete'); + console.warn('`package-lock.json` not found'); } diff --git a/package.json b/package.json index 00960e318..93015d569 100644 --- a/package.json +++ b/package.json @@ -83,8 +83,9 @@ "license": "(GPL-3.0 AND GFDL-1.3)", "scripts": { "start": "node app.js", - "preinstall": "node dev/preinit.js", - "postinstall": "node dev/postinit.js" + "preinstall": "node dev/preinstall.js", + "postinstall": "node dev/postinstall.js", + "clean": "node dev/clean.js" }, "engines": { "node": ">=8.9.0 <9.0.0",