diff --git a/js/appinfo.js b/js/appinfo.js index 151227f45..613d15379 100644 --- a/js/appinfo.js +++ b/js/appinfo.js @@ -27,14 +27,19 @@ var AppInfo = { // then map each file to a command to load into storage fileContents.forEach(storageFile => { // format ready for Espruino - var js; if (storageFile.evaluate) { - js = storageFile.content.trim(); + let js = storageFile.content.trim(); if (js.endsWith(";")) js = js.slice(0,-1); - } else - js = toJS(storageFile.content); - storageFile.cmd = `\x10require('Storage').write(${toJS(storageFile.name)},${js});`; + storageFile.cmd = `\x10require('Storage').write(${toJS(storageFile.name)},${js});`; + } else { + let code = storageFile.content; + // write code in chunks, in case it is too big to fit in RAM (fix #157) + var CHUNKSIZE = 4096; + storageFile.cmd = `\x10require('Storage').write(${toJS(storageFile.name)},${toJS(code.substr(0,CHUNKSIZE))},0,${code.length});`; + for (var i=CHUNKSIZE;i reject(err));