Skip to content

Commit

Permalink
fix(node.api): don’t ship tarball in JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
strogonoff committed Dec 20, 2023
1 parent efdb2ba commit 7f97040
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions node.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default (opts) => {
reduce((prev, curr) => ({ ...prev, ...{ [curr.npm.name]: curr } }), {})

for (const ext of Object.values(extensions).filter(ext => ext.tarball !== undefined)) {
// IMPORTANT: We don’t want that in JSON
const extDir = await unpackExtension(ext)
console.debug("Unpacked extension to temporary directory", ext.npm.name, extDir)

Expand Down Expand Up @@ -77,6 +78,7 @@ export default (opts) => {
};


/** Unpacks extension & deletes `tarball` from extension data. */
async function unpackExtension(ext) {
// This must be local, under process.cwd
const extDir = fs.mkdtempSync(path.join(
Expand All @@ -93,6 +95,9 @@ async function unpackExtension(ext) {
fs.writeFileSync(tarballPath, ext.tarball)
await tar.x({ file: tarballPath, cwd: extDir })

// IMPORTANT
delete ext.tarball;

return extDir;
}

Expand Down

0 comments on commit 7f97040

Please sign in to comment.