-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.js
53 lines (51 loc) · 1.68 KB
/
clean.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*!
* ==========================================================================
* "CoPoKo Whitehole" License
* GNU General Public License version 3.0 (GPLv3)
* ==========================================================================
* This file is part of "CoPoKo Whitehole"
*
* "CoPoKo Whitehole" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* "CoPoKo Whitehole" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with "CoPoKo Whitehole". If not, see <http://www.gnu.org/licenses/>.
* ==========================================================================
*/
const fs = require('fs')
let myFileList = [
"./.git",
"./.github",
"./.npmignore",
"./LICENSE",
"./npm-version-bump.js",
"./clean.js",
"./package.json",
"./README.md",
];
function deleteall(path) {
var files = [];
if (fs.existsSync(path)) {
files = fs.readdirSync(path);
files.forEach(function (file, index) {
var curPath = path + "/" + file;
// console.log(curPath);
if (myFileList.indexOf(curPath) == -1) {
console.log(curPath);
if (fs.statSync(curPath).isDirectory()) { // recurse
deleteall(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
}
});
}
};
deleteall(".");