Skip to content

Commit 568367d

Browse files
committed
Check for valid package installation archive (#28)
1 parent 4c6a40a commit 568367d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/packages.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,16 @@ class Packages {
181181
await fs.mkdir(target);
182182
await extract(stream, target);
183183

184-
const filenames = await fg(root + '/*/metadata.json');
184+
// FIXME: npm packages have a 'package' subdirectory
185+
if (!await fs.exists(path.resolve(target, 'metadata.json'))) {
186+
await fs.unlink(target);
187+
188+
throw new Error('Invalid package');
189+
}
190+
191+
// TODO: Check conflicts ?
192+
193+
const filenames = await fg(root + '/*/metadata.json'); // FIXME: Windows!
185194
const metadatas = await Promise.all(filenames.map(f => fs.readJson(f)));
186195

187196
await fs.writeJson(manifest, metadatas);

0 commit comments

Comments
 (0)