MCPcopy Create free account
hub / github.com/VonChange/utao / writeFile

Function writeFile

util/ya/ya.js:49–69  ·  view source on GitHub ↗
(src,to)

Source from the content-addressed store, hash-verified

47 return folders.indexOf(folder) !== -1;
48 },
49 writeFile(src,to){
50 //console.log("writeFile "+src+" "+to);
51 if(src.endsWith(".js")||src.endsWith(".html")){
52 fs.readFile(src, utf8,function (err,data){
53 //逻辑处理 版本替换逻辑
54 if(src.endsWith(".js")&&!src.endsWith(".min.js")){
55 if(src.indexOf("load_")>0){
56 data= ya.workVersion(data);
57 }
58 }
59 if(src.endsWith(".html")){
60 //data= ya.workVersion(data);
61 }
62 fs.writeFileSync(to,data,utf8);
63 });
64 }else{
65 fs.readFile(src,function (err,data){
66 fs.writeFileSync(to,data);
67 });
68 }
69 },
70 workVersion(data){
71 return data.replaceAll("?v=x","?v="+currentTime);
72 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected