Files
vue-cli/packages/@vue/cli/lib/inspect.js
Jarrod Davis 0f9a44a77a fix(inspect): correct usage of resolve (#773)
Use `basedir` to specify the initial search path for resolving the CLI
service, since `cwd` is not a valid option property.
2018-02-04 10:49:38 -05:00

26 lines
735 B
JavaScript

const fs = require('fs')
const path = require('path')
const execa = require('execa')
const resolve = require('resolve')
module.exports = function inspect (paths, mode) {
const cwd = process.cwd()
let servicePath
try {
servicePath = resolve.sync('@vue/cli-service', { basedir: cwd })
} catch (e) {
const { error } = require('@vue/cli-shared-utils')
error(`Failed to locate @vue/cli-service. Make sure you are in the right directory.`)
process.exit(1)
}
const binPath = path.resolve(servicePath, '../../bin/vue-cli-service.js')
if (fs.existsSync(binPath)) {
execa('node', [
binPath,
'inspect',
...(mode ? ['--mode', mode] : []),
...paths
], { cwd, stdio: 'inherit' })
}
}