0.1.1 • Published 8 years ago
leave-me-alone v0.1.1
中心化不同渠道代码的抽离工具
动机
- 项目已经分离,需要消除冗余代码
- 方便阅读代码和梳理业务逻辑
- 避免僵尸复活祸害人间
DEMO
安装
$ sudo npm install git+http://git.mucfc.com/chenhanjie/leave-me-alone.git -g --registry=https://registry.npm.taobao.org
因为是cli命令
,所以需要全局安装。
简易命令
$ leave-me-alone wechat
$ leave-me-alone app
详细用法
- 帮助
leave-me-alone -h
Usage: leave-me-alone [options] [command]
Commands:
wechat|w [options] [filepath] 只保留wechat代码
app|a [options] [filepath] 只保留app代码
*
Options:
-h, --help output usage information
-V, --version output the version number
- 只保留当前目录各文件wechat渠道的代码
$ cd your-fold
$ leave-me-alone wechat
- 只保留当前目录各文件的App渠道的代码
$ cd your-fold
$ leave-me-alone app
- 只处理指定的子目录或文件中的代码
指定的目录为当前执行目录的子目录,文件为当前目录中的文件
$ cd your-fold
// 指定目录
$ leave-me-alone wechat your/subfold/
// 指定文件
$ leave-me-alone wechat your/subfold/filename.suffix
- 只处理特定的文件类型
目前支持的文件类型为html
、tpl
和js
$ cd your-fold
// 只处理html文件
$ leave-me-alone wechat -s html
// 多种文件类型使用半角逗号(,)间隔
$ leave-me-alone wechat -s html,tpl,js
建议
最好在工程的src/pages
或其子目录下运行。直接在工程目录运行会处理src/components
中的文件。
- 项目的
src/componets
中,也有需要抽离的代码,但是作为基础模块,抽离是否合适,或src/componets
本应该跟渠道无关。
对目录转换后,使用diff工具检查一下,diff的高亮,可以很快看出抽离是否正确。
效果
运行$ leave-me-alone wechat
html result
tpl result
js result
测试
$ git clone http://git.mucfc.com/chenhanjie/leave-me-alone.git
$ cd levae-me-alone
$ npm run test
TODO
windows上的兼容性✔- 在中心化构建中移除
process
过程
END
0.1.1
8 years ago