pksunkara / electron-plugin-manager

Plugin Manager based on NPM for Electron apps
MIT License
8 stars 3 forks source link

Crashes on bad directory/malformed package.json #79

Open Allow2CEO opened 3 years ago

Allow2CEO commented 3 years ago

Probably need some extra checks in the code.

I had a .idea folder in the plugins directory and also had a test plugin in there that had a syntax error in the package.json (missing key quotes, duh!)

Anyway, the epm.list function (and maybe others) should probably just reject (or log) any non-compliant plugin folders. Such as if package.json is missing or cannot be JSON parsed.

pksunkara commented 3 years ago

What was the error message/stacktrace you were getting?

IIRC, the plugin uses pacote (used by npm) underneath to load the packages. I guess it assumes that everything is valid.

Allow2CEO commented 3 years ago

Ah, maybe a couple of basic pre-checks then. npm is more a developer-side tool, the end user won't know that a spurious folder or corrupted package.json is causing your app to crash.

The error is easy to reproduce, put a blank folder in plugins folder, or modify a package.json to be invalid.

Nice library by the way. Using it to make our parental freedom automation app extensible.

pksunkara commented 3 years ago

I think I can do something to improve here. But can you please help me with what other functions fail?

Allow2CEO commented 3 years ago

Sure, simple improvement here and I'll post other issues as I come across them. Thanks!