my-cli-test (npm explain)

technical standard

  • react、redux、reducer
  • antd
  • less
  • type-script
  • webpack

guide

  • npm install cli-redux-ts // pull npm scaffold
  • cd node_modules // to scaffold path
  • npm install -g // install npm scaffold
  • my-cli // initialize scaffold
  • npm install // install package
  • npm start // start project

https://www.npmjs.com/package/cli-redux-ts

KEY CODE

#! node
console.log("hello cli!")
const fileManager = require("./file-manager")
const path = require("path")

fileManager.init()
let fromdir = path.join(__dirname, 'templates')
let todir = path.join(__dirname, 'src')

fileManager.mkdir('./src', function () {
  fileManager.copyFolder(fromdir, todir)
})
  copyFolder(from, to) {
    let folder = fs.readdirSync(from)
    folder.forEach((file) => {
      let fromPathname = path.join(from, file)
      let toPathname = path.join(to, file)
      if (fs.statSync(fromPathname).isDirectory()) {
        fs.mkdir(toPathname, (err) => {
          if (err) throw { err, fromPathname, toPathname };
          else {
            this.copyFolder(fromPathname,toPathname)
            console.log("mkdirCircle")
          }
        });
      } else {
        this.copyFile(fromPathname, toPathname)
      }
    })
  },

 

## key word

commander

exec

fs.mkdir

本地实现了npm 执行

npm login

npm publish

 

 

npm install  拉取命令行工具

my-cli

my cli note 
node编写自己的cli:
https://www.cnblogs.com/Leo_wl/p/6901603.html
cli原理解析:
https://blog.csdn.net/weixin_33795743/article/details/91428525

echo $PATH 查看配置的环境变量
myCli 地址: C:\Users\sesa528506\AppData\Roaming\npm
 

ref['http://www.ruanyifeng.com/blog/2015/05/command-line-with-node.html']

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值