Skip to content

Commit

Permalink
fix: load extensions error when path doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmaddock committed Nov 26, 2024
1 parent af33519 commit 2214130
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/electron-chrome-web-store/src/browser/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ const manifestExists = async (dirPath: string) => {
* Discover list of extensions in the given path.
*/
async function discoverExtensions(extensionsPath: string): Promise<ExtensionPathInfo[]> {
try {
const stat = await fs.promises.stat(extensionsPath)
if (!stat.isDirectory()) {
d('%s is not a directory', extensionsPath)
return []
}
} catch {
d('%s does not exist', extensionsPath)
return []
}

// Get top level directories
const subDirectories = await fs.promises.readdir(extensionsPath, {
withFileTypes: true,
Expand Down Expand Up @@ -97,7 +108,7 @@ export async function loadAllExtensions(
allowUnpacked: boolean
) {
const extensions = await discoverExtensions(extensionsPath)
d('discovered %d extension(s)', extensions.length)
d('discovered %d extension(s) in %s', extensions.length, extensionsPath)

for (const ext of extensions) {
try {
Expand Down

0 comments on commit 2214130

Please sign in to comment.