Skip to content

Commit

Permalink
add a npm script to clean static files collected by webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiaoyi0504 committed Dec 19, 2018
1 parent e9e9eec commit 71263a3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 131 deletions.
125 changes: 0 additions & 125 deletions blast/static/blast/scripts/dragscrollable.js

This file was deleted.

5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "genomics-workspace",
"version": "1.0.0",
"scripts": {
"build": "npm install && webpack && python2.7 setup.py"
"build": "npm install && webpack && python2.7 setup.py",
"clean": "node util/clean.js"
},
"private": true,
"repository": {
Expand Down
50 changes: 50 additions & 0 deletions util/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const fs = require('fs');
const path = require('path');

const deleteFolderRecursive = function(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file, index){
var curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};

const projectRootPath = path.resolve(__dirname, '..');
const gitIgnorePath = path.resolve(projectRootPath, '.gitignore');

let files = fs.readFileSync(gitIgnorePath)
.toString()
.split('\n')
.filter(function(data){
if (
data !== '' &&
!data.startsWith('#') &&
!data.startsWith('*') &&
!data.startsWith('.')
) {
if (
data.startsWith('/app/static') ||
data.startsWith('/blast/static') ||
data.startsWith('/clustal/static') ||
data.startsWith('/hmmer/static')
)
return true;
}
});

for (let f of files) {
f = path.resolve(projectRootPath, '.' + f);
if (fs.existsSync(f)) {
if (fs.lstatSync(f).isDirectory()) {
deleteFolderRecursive(f);
} else {
fs.unlinkSync(f);
}
}
}

0 comments on commit 71263a3

Please sign in to comment.