Skip to content

Commit a3403f3

Browse files
committed
fix: cannot find package.json in folders ziped with windows right click
1 parent 8d18cd5 commit a3403f3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/utils/zipUtils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ function getExtensionPackageJSON(zipPath) {
1616
zip.entries().then(entries=>{
1717
for (const entry of Object.values(entries)) {
1818
let pathSplit = entry.name.split("/");
19-
rootFolders[pathSplit[0]] = true;
19+
if(entry.isDirectory || pathSplit.length > 1) {
20+
// windows compression util only generates Directory entries if a directory is empty.
21+
// else it will list only files in non-empty dirs. So we check if the path if of the form
22+
// a/b[/c...json] to detect rootFolders implicitly conveyed by file paths.
23+
rootFolders[pathSplit[0]] = true;
24+
}
2025
if(entry.isFile && (entry.name === "package.json" || entry.name.endsWith("/package.json"))) {
2126
packageJSONFilePaths[entry.name] = entry;
2227
}

0 commit comments

Comments
 (0)