Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

记录平时开发中遇到的问题(长期更新) #2

Open
programmer-yang opened this issue Sep 15, 2017 · 0 comments
Open

记录平时开发中遇到的问题(长期更新) #2

programmer-yang opened this issue Sep 15, 2017 · 0 comments
Labels

Comments

@programmer-yang
Copy link
Owner

programmer-yang commented Sep 15, 2017

[TOC]

关于npm中的参数传递

我在使用package.jsonscripts命令的时候遇到了一个参数传递问题
npm run build -type all这条命令中的--type all参数无法继承到npm run build命令具体执行的那条命令上去

解决办法

npm run build -- -type all

npm命令中,--后的内容会继承到真实的命令中去

关于写命令配置参数

这个其实比较自由,实现的方法很多,就像一个网站,你可以使用jquery、php、jsp、react、vue、ng中的任何一种来实现一样,用你觉得对的语法就好,当然,我这里还是要推荐下我觉得挺好的语法

const argv = yargs.option('t', {
  alias: 'type',
  demand: true,
  describe: '类型',
  type: 'string'
}).argv;

yargs是个很强大的库,推荐给大家 链接

可能会用到的库

最近写个工具,用到了一些库,记录一下,同时也推荐给大家

const rimraf = require('rimraf');
const copydir = require('copy-dir');
const chalk = require('chalk');

copy-dir-参考
rimraf-参考
chalk-参考

rimraf 用于清空文件夹相当于rm -rf,所以用起来小心一点,主要用于编译等操作之前清空目标文件

  rimraf.sync('./public/*');

copydir复制文件夹,支持同步异步操作`

  copydir.sync('a', 'b');
// a 源文件夹 b目标文件夹

chalk可以在控制台输出不同颜色的信息,用于写工具提醒的提醒信息,告别单调的console.log('xxx')

console.log(chalk.red('hello world'));
@programmer-yang programmer-yang changed the title 记录点平时开发中遇到的问题(长期更新) 记录平时开发中遇到的问题(长期更新) Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant