-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrip.js
More file actions
39 lines (31 loc) · 1.02 KB
/
strip.js
File metadata and controls
39 lines (31 loc) · 1.02 KB
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
let stripDebug = require('strip-debug');
let fs = require('fs');
let path = require('path');
let output ="";
let dist = "./dist"
function fromDir(startPath,filter){
//console.log('Starting from dir '+startPath+'/');
if (!fs.existsSync(startPath)){
console.log("no dir ",startPath);
return;
}
var files=fs.readdirSync(startPath);
for(var i=0;i<files.length;i++){
var filename=path.join(startPath,files[i]);
var stat = fs.lstatSync(filename);
if (stat.isDirectory()){
fromDir(filename,filter); //recurse
}
else if (filename.indexOf(filter)>=0) {
console.log('-- found: ',filename);
let data = fs.readFileSync(filename).toString();
fs.writeFileSync(filename, stripDebug(data).toString(), function(err) {
if(err) {
return console.log(err);
}
console.log("The file "+filename +" was stripped!");
});
};
};
};
fromDir(dist,'main');