-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a npm script to clean static files collected by webpack
- Loading branch information
1 parent
e9e9eec
commit 81bf51f
Showing
4 changed files
with
50 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const deleteFolderRecursive = function(path) { | ||
fs.readdirSync(path).forEach(function(file, index){ | ||
let 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); | ||
} | ||
} | ||
} |