mirror of
https://github.com/amark/gun.git
synced 2025-06-12 17:16:44 +00:00
unbuild is no longer silent (#1239)
* prepare to sync gun lib unbuild on npm install * Update unbuild.js * Update package.json * Update package.json
This commit is contained in:
parent
8facbcc095
commit
42720c57ea
@ -19,6 +19,13 @@ var mk = function(path){
|
||||
fs.mkdirSync(path);
|
||||
}
|
||||
|
||||
var rn = function(path, newPath){
|
||||
path = nodePath.join(dir, path)
|
||||
newPath = nodePath.join(dir, newPath)
|
||||
if(fs.existsSync(newPath)){ return }
|
||||
fs.renameSync(path, newPath);
|
||||
}
|
||||
|
||||
var between = function(text, start, end){
|
||||
end = end || start;
|
||||
var s = text.indexOf(start);
|
||||
@ -65,15 +72,19 @@ var undent = function(code, n){
|
||||
|
||||
var arg = process.argv[2] || 'gun';
|
||||
|
||||
var g;
|
||||
if('gun' === arg){
|
||||
rm('./src');
|
||||
g = 'gun';
|
||||
rn('./src','./old_src');
|
||||
mk('./src');
|
||||
mk('./src/polyfill');
|
||||
mk('./src/adapters');
|
||||
} else {
|
||||
rm('./'+arg);
|
||||
g = arg;
|
||||
rn('./'+arg,'./old_'+arg);
|
||||
mk('./'+arg);
|
||||
}
|
||||
console.log("unbuild:", arg+'.js')
|
||||
|
||||
var f = read(arg+'.js');
|
||||
var code = next(f);
|
||||
@ -81,7 +92,7 @@ var undent = function(code, n){
|
||||
|
||||
code = next("/* UNBUILD */");
|
||||
|
||||
if('gun' === arg){
|
||||
if('gun' === g){
|
||||
write('src/polyfill/unbuild.js', undent(code, 1));
|
||||
arg = '';
|
||||
}
|
||||
@ -92,7 +103,20 @@ var undent = function(code, n){
|
||||
var file = path(arg);
|
||||
if(!file){ return }
|
||||
code = code.replace(/\bUSE\(/g, 'require(');
|
||||
write(file, undent(code));
|
||||
code = undent(code);
|
||||
var rcode;
|
||||
try{ rcode = read('old_'+file); } catch(e){}
|
||||
// console.log(rcode);
|
||||
if(rcode != code){
|
||||
console.log("unbuild:","update",file);
|
||||
}
|
||||
write(file, code);
|
||||
recurse();
|
||||
}());
|
||||
if('gun' === g){
|
||||
rm('./old_src');
|
||||
}else{
|
||||
rm('./old_'+g);
|
||||
}
|
||||
|
||||
}());
|
||||
|
Loading…
x
Reference in New Issue
Block a user