vue create [project-name]做了什么?

先看一下vue create生成的log

Vue CLI v3.4.1
? Please pick a preset: default (babel, eslint)

Vue CLI v3.4.1
✨  Creating project in /Users/wangweiren/Documents/project/vue-hello.
?  Initializing git repository...
⚙  Installing CLI plugins. This might take a while...

// https://www.npmjs.com/package/fsevents
// 可以监听某个目录
> fsevents@1.2.7 install /Users/wangweiren/Documents/project/vue-hello/node_modules/fsevents
> node install

[fsevents] Success: "/Users/wangweiren/Documents/project/vue-hello/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is ins
talled via remote

> yorkie@2.0.0 install /Users/wangweiren/Documents/project/vue-hello/node_modules/yorkie
> node bin/install.js

setting up Git hooks
done

added 1181 packages from 657 contributors and audited 23486 packages in 57.302s
found 0 vulnerabilities

?  Invoking generators...
?  Installing additional dependencies...

added 37 packages from 28 contributors, updated 2 packages, moved 9 packages and audited 23774 packages in 28.952s
found 0 vulnerabilities

⚓  Running completion hooks...

?  Generating README.md...

?  Successfully created project vue-hello.
?  Get started with the following commands:

$ cd vue-hello
$ npm run serve

vue 命令的node代码

#!/usr/bin/env node

program
  .command('create <app-name>')
  .description('create a new project powered by vue-cli-service')
  .option('-p, --preset <presetName>', 'Skip prompts and use saved or remote preset')
  .option('-d, --default', 'Skip prompts and use default preset')
  .option('-i, --inlinePreset <json>', 'Skip prompts and use inline JSON string as preset')
  .option('-m, --packageManager <command>', 'Use specified npm client when installing dependencies')
  .option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
  .option('-g, --git [message]', 'Force git initialization with initial commit message')
  .option('-n, --no-git', 'Skip git initialization')
  .option('-f, --force', 'Overwrite target directory if it exists')
  .option('-c, --clone', 'Use git clone when fetching remote preset')
  .option('-x, --proxy', 'Use specified proxy when creating project')
  .option('-b, --bare', 'Scaffold project without beginner instructions')
  .action((name, cmd) => {
    const options = cleanArgs(cmd)

    if (minimist(process.argv.slice(3))._.length > 1) {
   
      console.log(chalk.yellow('\n Info: You provided more than one argument. The first one will be used as the app\'s name, the rest are ignored.'))
    }
    // --git makes commander to default git to true
    if (process.argv.includes('-g') || process.argv.includes('--git')) {
   
      options.forceGit = true
    }
    require('../lib/create')(name, options)
  })

发现用了当前目录上一级/lib/create这个文件,我们接着看一下,发现这个文件做了一系列的判断之后~,然后执行了


const creator = new Creator(name, targetDir, getPromptModules());
await creator.create(options)

create方法


                
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值