Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
fix: use the option to throw instead of listening on process
Browse files Browse the repository at this point in the history
  • Loading branch information
amphro committed Mar 15, 2018
1 parent ef86e2d commit 4d3fd4f
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/commands/manifest.ts
Expand Up @@ -11,25 +11,13 @@ export default class Manifest extends Command {
{name: 'path', description: 'path to plugin', default: '.'}
]

capturePluginWarning(warning: Error) {
if (warning.name.match(/Plugin:/)) { throw warning }
}

async run() {
try { fs.unlinkSync('.oclif.manifest.json') } catch {}
const {args} = this.parse(Manifest)
const root = path.resolve(args.path)
let plugin = new Config.Plugin({root, type: 'core', ignoreManifest: true})
let plugin = new Config.Plugin({root, type: 'core', ignoreManifest: true, errorOnManifestCreate: true})
if (!plugin) throw new Error('plugin not found')
process.addListener('warning', this.capturePluginWarning)
try {
await plugin.load()
// Wait for event queue to flush so we get any potential warning.
await new Promise(resolve => process.nextTick(resolve))
} finally {
// Clean up
process.removeListener('warning', this.capturePluginWarning)
}
await plugin.load()
if (!plugin.valid) {
// @ts-ignore
let p = require.resolve('@oclif/plugin-legacy', {paths: [process.cwd()]})
Expand Down

0 comments on commit 4d3fd4f

Please sign in to comment.