Skip to content

Commit

Permalink
sdk: fix excessive zipping
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Aug 17, 2024
1 parent 075d8bc commit 17900f0
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions sdk/bin/scrypted-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,6 @@ else {
return reject(new Error('webpack failed'));
}

// create a zip that has a main.js in the root, and an fs folder containing a read only virtual file system.
// todo: read write file system? seems like a potential sandbox and backup nightmare to do a real fs. scripts should
// use localStorage, etc?
const jsFiles = fs.readdirSync(out, {
withFileTypes: true
}).filter(ft => ft.isFile() && ft.name.endsWith('.js')).map(ft => ft.name);
for (const js of jsFiles) {
zip.addLocalFile(path.join(out, js));
const sourcemap = path.join(out, js + '.map');
if (fs.existsSync(sourcemap))
zip.addLocalFile(sourcemap);
console.log(js);
}
resolve();
})
});
Expand All @@ -196,6 +183,20 @@ else {

await Promise.all(promises);

// create a zip that has a main.nodejs.js in the root, and an fs folder containing a read only virtual file system.
// todo: read write file system? seems like a potential sandbox and backup nightmare to do a real fs. scripts should
// use localStorage, etc?
const jsFiles = fs.readdirSync(out, {
withFileTypes: true
}).filter(ft => ft.isFile() && ft.name.endsWith('.js')).map(ft => ft.name);
for (const js of jsFiles) {
zip.addLocalFile(path.join(out, js));
const sourcemap = path.join(out, js + '.map');
if (fs.existsSync(sourcemap))
zip.addLocalFile(sourcemap);
console.log(js);
}

const zipfs = path.join(cwd, 'fs');
if (fs.existsSync(zipfs))
zip.addLocalFolder(zipfs, 'fs');
Expand Down

0 comments on commit 17900f0

Please sign in to comment.