@@ -161,10 +161,12 @@ let outputFileComplete = (dst,fn) => {
161161 // with no semicolon we don't end up with (function(){ ... }()(function(){ ... }()
162162 // which would cause an error!
163163 // we write:
164- // "//"+bootFile+"\n"+require('Storage').read(bootFile)+";\n";
164+ // "//"+bootFile+"\n"+require('Storage').read(bootFile)+"\n ;\n";
165165 // but we need to do this without ever loading everything into RAM as some
166166 // boot files seem to be getting pretty big now.
167- outputFile ( dst , fn , "" , ";\n" ) ;
167+ // The newline before the semicolon ensures that if the file ends in a
168+ // `// comment` with no trailing newline, the comment doesn't swallow it (#3939)
169+ outputFile ( dst , fn , "" , "\n;\n" ) ;
168170} ;
169171fileOffset = boot . length + bootPost . length ;
170172bootFiles . forEach ( fn => outputFileComplete ( undefined , fn ) ) ; // just get sizes
@@ -180,7 +182,8 @@ let widget = `// Made by bootupdate.js\nglobal.WIDGETS={};`, widgetPost = `var W
180182Object.keys(W).sort((a,b)=>(0|W[b].sortorder)-(0|W[a].sortorder)).forEach(k=>WIDGETS[k]=W[k]);` ; // sort
181183if ( DEBUG ) widget += "var _tm=Date.now();" ;
182184outputFileComplete = ( dst , fn ) => {
183- outputFile ( dst , fn , "try{" , `}catch(e){print(${ E . toJS ( fn ) } ,e,e.stack)}\n` ) ;
185+ // newline before ' }' in case the widget ends in a '// comment' (#3939)
186+ outputFile ( dst , fn , "try{" , `\n}catch(e){print(${ E . toJS ( fn ) } ,e,e.stack)}\n` ) ;
184187} ;
185188fileOffset = widget . length + widgetPost . length ;
186189widgetFiles . forEach ( fn => outputFileComplete ( undefined , fn ) ) ; // just get sizes
@@ -197,7 +200,8 @@ let ci_exclude = (require("Storage").readJSON("clock_info.json", 1) || {}).exclu
197200if ( DEBUG ) ci += "var _tm=Date.now();" ;
198201outputFileComplete = ( dst , fn ) => {
199202 if ( ci_exclude && ci_exclude [ fn ] ) return ;
200- outputFile ( dst , fn , "try{let fn=" , `;let a=fn(),b=menu.find(x=>x.name===a.name);if(b)b.items=b.items.concat(a.items)else menu=menu.concat(a);}catch(e){print(${ E . toJS ( fn ) } ,e,e.stack)}\n` ) ;
203+ // newline before ';' in case the clockinfo ends in a '// comment' (#3939)
204+ outputFile ( dst , fn , "try{let fn=" , `\n;let a=fn(),b=menu.find(x=>x.name===a.name);if(b)b.items=b.items.concat(a.items)else menu=menu.concat(a);}catch(e){print(${ E . toJS ( fn ) } ,e,e.stack)}\n` ) ;
201205} ;
202206fileOffset = ci . length ;
203207ciFiles . forEach ( fn => outputFileComplete ( undefined , fn ) ) ; // just get sizes
0 commit comments