Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
api.setProgress({
status: 'org.vue.cli-service.suggestions.progress',
args: [id],
progress: -1
})
const context = api.getCwd()
let error
try {
const servicePkg = loadModule('@vue/cli-service/package.json', context)
// @vue/cli-plugin-router is not compatible with @vue/cli-service v3,
// so we have to check for the version and call the right generator
if (semver.satisfies(servicePkg.version, '3.x')) {
await invoke.runGenerator(context, {
id: `core:${id}`,
apply: loadModule(`@vue/cli-service/generator/${id}`, context)
})
} else {
// FIXME: a temporary fix for adding router plugin
// should implement a plugin prompt ui later
await add(id, { $inlineOptions: '{}' }, context)
}
} catch (e) {
error = e
}
api.removeProgress()
if (error) throw error
}