Skip to content

Commit

Permalink
feat: adding support fail loudly.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinheidegger committed Apr 29, 2022
1 parent f02e735 commit e9a9509
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ If you still want to use these, you need to pass the `strict = false` option.
await loadPlugins(plugins, { strict: false })
```
By default there will be also no error if the installation of the plugins happens
to fail. In order to enable errors you need to pass `failQuietly=false`.
```js
await loadPlugins(plugins, { failQuietyl: false })
```
To install private packages you will need to specify an authentication token.
```js
Expand Down
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ async function assertInstalled (plugins: FNOrResult<PluginDefinitions>, opts: Lo
await writeFile(state.path, JSON.stringify(stateFs))
return installedNames
} catch (err) {
if (!opts.failQuietly) {
throw Object.assign(new Error(`Error while installing the current plugins (${installedNames.join(', ')}): ${String(err)}`), { cause: err })
}
debug('Error while installing the current plugins: %s, %s', installedNames, err)
return []
}
Expand Down Expand Up @@ -344,6 +347,7 @@ export interface LoadPluginsOptions extends Omit<ConfigOpts, 'home'> {
tmpDir: string
maxAge: number
strict: boolean
failQuietly: boolean
/**
* A list of registry tokens to access private npm registries
*/
Expand All @@ -354,6 +358,7 @@ export async function loadPlugins (plugins: FNOrResult<PluginDefinitions>, opts:
const normalizedOpts = {
tmpDir: DEFAULT_TMP_DIR,
maxAge: DEFAULT_MAX_AGE,
failQuietly: true,
strict: true,
...opts
}
Expand Down

0 comments on commit e9a9509

Please sign in to comment.