最近看vue-cli 2.9.0源碼的時(shí)候看到bin文件下的vue文件中定義了一些指令#!/usr/bin/env noderequire('commander')
.version(require('../package').version)
.usage('<command> [options]')
.command('init', 'generate a new project from a template')
.command('list', 'list available official templates')
.command('build', 'prototype a new project')
.parse(process.argv)同時(shí)在bin文件夾下還有 vue-init、vue-list等文件。我想請問一下,為什么在commander中定義init指令之后,在命令行輸入vue init 指令,可以去執(zhí)行vue-init里面的代碼,這是怎么樣的一種實(shí)現(xiàn)原理,還是npm幫我們做了這個(gè)事情。
關(guān)于npm項(xiàng)目中的bin文件
青春有我
2018-10-24 10:09:18