Commit e02455fd authored by 谢卓城's avatar 谢卓城

新增:可配置生成文件名与文件夹名相同

parent 34606ef7
...@@ -10,8 +10,19 @@ ...@@ -10,8 +10,19 @@
### 使用 ### 使用
``` ```
npm run page -- nmpage 创建名为nmpage的page文件 npm run page <#name#> 创建名为<#name#>的page文件(文件与<#name#>同名)
npm run component -- nmcomponent 创建名为nmcomponent的component文件 npm run page:i <#name#> 创建名为<#name#>的page文件(文件都为index.*)
npm run component <#name#> 创建名为<#name#>的component文件(文件与<#name#>同名)
npm run component:i <#name#> 创建名为<#name#>的component文件(文件都为index.*)
npm run build:ci 生成miniprogram_npm文件
npm run dev 开启小程序实时转码服务
npm run devBuild 小程序编译
npm run dev:package <#name#> 小程序开发环境安装<#name#>npm包
npm run package <#name#> 小程序生产环境安装<#name#>npm包
npm run dev:un <#name#> 小程序开发环境卸载<#name#>npm包
npm run un <#name#> 小程序生产环境卸载<#name#>npm包
gulp new -c mycomponent -t Test 以Test为模版创建mypage的component目录 gulp new -c mycomponent -t Test 以Test为模版创建mypage的component目录
gulp new -p mypage -t Test 以Test为模版创建mypage的page目录 gulp new -p mypage -t Test 以Test为模版创建mypage的page目录
......
...@@ -156,6 +156,11 @@ const newfile = done => { ...@@ -156,6 +156,11 @@ const newfile = done => {
alias: "template", alias: "template",
describe: "components里的模板", describe: "components里的模板",
type: "string" type: "string"
},
i: {
alias: "index",
describe: "page、components生成的文件与文件夹名称一致",
type: "string"
} }
}) })
.fail(msg => { .fail(msg => {
...@@ -195,7 +200,13 @@ const newfile = done => { ...@@ -195,7 +200,13 @@ const newfile = done => {
? `./.${source}/${type}/${page}/*` ? `./.${source}/${type}/${page}/*`
: `./.${type}/${source}/${page}/*`; : `./.${type}/${source}/${page}/*`;
return gulp.src(defaultPath).pipe(gulp.dest(`src/${type}/${name}/`)); var stream = gulp.src(defaultPath);
if (args.i == "0") {
stream = stream.pipe(rename({ basename: name.toLowerCase() }));
}
return stream.pipe(gulp.dest(`src/${type}/${name}/`));
}; };
gulp.task("new", newfile); gulp.task("new", newfile);
......
...@@ -13,9 +13,11 @@ ...@@ -13,9 +13,11 @@
"dev:package": "sh ./package/package.sh -d 1 -u 0 -p", "dev:package": "sh ./package/package.sh -d 1 -u 0 -p",
"package": "sh ./package/package.sh -d 0 -u 0 -p", "package": "sh ./package/package.sh -d 0 -u 0 -p",
"dev:un": "sh ./package/package.sh -d 1 -u 1 -p", "dev:un": "sh ./package/package.sh -d 1 -u 1 -p",
"uninstall": "sh ./package/package.sh -d 0 -u 1 -p", "un": "sh ./package/package.sh -d 0 -u 1 -p",
"page": "gulp new -p", "page": "gulp new -i 0 -p",
"component": "gulp new -c" "page:i": "gulp new -p",
"component": "gulp new -i 0 -c",
"component:i": "gulp new -c"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
......
...@@ -17,7 +17,7 @@ while getopts 'd:u:p:' args;do ...@@ -17,7 +17,7 @@ while getopts 'd:u:p:' args;do
unInstall=$OPTARG unInstall=$OPTARG
;; ;;
p) p)
echo 'use -u :' $OPTARG echo 'use -p :' $OPTARG
package=$OPTARG package=$OPTARG
;; ;;
esac esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment