Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some *npm* scripts for maintainance. #1437

Merged
merged 1 commit into from
Jun 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions dev/clean.js
Original file line number Diff line number Diff line change
@@ -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/');


File renamed without changes.
2 changes: 1 addition & 1 deletion dev/preinit.js → dev/preinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down