mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-30 00:41:12 -05:00
feat: vue inspect that proxies to vue-cli-service
This commit is contained in:
@@ -54,6 +54,14 @@ program
|
||||
require('../lib/invoke')(plugin, minimist(process.argv.slice(3)))
|
||||
})
|
||||
|
||||
program
|
||||
.command('inspect [paths...]')
|
||||
.option('--mode <mode>')
|
||||
.description('inspect the webpack config in a project with vue-cli-service')
|
||||
.action((paths, cmd) => {
|
||||
require('../lib/inspect')(paths, cmd.mode)
|
||||
})
|
||||
|
||||
program
|
||||
.command('serve [entry]')
|
||||
.description('serve a .js or .vue file in development mode with zero config')
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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', { 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' })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user