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:
Bradley Matusiak 2022-05-30 23:02:25 -04:00 committed by GitHub
parent 8facbcc095
commit 42720c57ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,13 @@ var mk = function(path){
fs.mkdirSync(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){ var between = function(text, start, end){
end = end || start; end = end || start;
var s = text.indexOf(start); var s = text.indexOf(start);
@ -65,15 +72,19 @@ var undent = function(code, n){
var arg = process.argv[2] || 'gun'; var arg = process.argv[2] || 'gun';
var g;
if('gun' === arg){ if('gun' === arg){
rm('./src'); g = 'gun';
rn('./src','./old_src');
mk('./src'); mk('./src');
mk('./src/polyfill'); mk('./src/polyfill');
mk('./src/adapters'); mk('./src/adapters');
} else { } else {
rm('./'+arg); g = arg;
rn('./'+arg,'./old_'+arg);
mk('./'+arg); mk('./'+arg);
} }
console.log("unbuild:", arg+'.js')
var f = read(arg+'.js'); var f = read(arg+'.js');
var code = next(f); var code = next(f);
@ -81,7 +92,7 @@ var undent = function(code, n){
code = next("/* UNBUILD */"); code = next("/* UNBUILD */");
if('gun' === arg){ if('gun' === g){
write('src/polyfill/unbuild.js', undent(code, 1)); write('src/polyfill/unbuild.js', undent(code, 1));
arg = ''; arg = '';
} }
@ -92,7 +103,20 @@ var undent = function(code, n){
var file = path(arg); var file = path(arg);
if(!file){ return } if(!file){ return }
code = code.replace(/\bUSE\(/g, 'require('); 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(); recurse();
}()); }());
if('gun' === g){
rm('./old_src');
}else{
rm('./old_'+g);
}
}()); }());