Skip to content

Commit

Permalink
feat(alita): 添加--wxName 配合--comp使用 ,指定小程序平台的包名
Browse files Browse the repository at this point in the history
  • Loading branch information
ykforerlang committed Oct 27, 2019
1 parent 7176ace commit 42f66d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ const options = getopts(process.argv, {
v: 'version',
config: 'config',
beta: 'beta',
comp: 'component'
comp: 'component',
wxName: "wxName"
},
})

Expand Down Expand Up @@ -147,6 +148,11 @@ if (enterO() && !options.outdir) {
console.log('output dir must exists, check your -o argument'.error)
process.exit()
}

if (options.component && !options.wxName) {
console.log('--comp 需要配合 --wxName使用,来指定wx平台的包名!'.warn)
}

const OUT_DIR = path.resolve(options.outdir, options.component ? 'miniprogram_npm': '')

console.log(`输入目录: ${INPUT_DIR}`.info)
Expand Down Expand Up @@ -209,7 +215,7 @@ function main() {
geneWXFileStruc(OUT_DIR, options.component)

// 生成微信package.json文件
geneWXPackageJSON()
geneWXPackageJSON(options.wxName)

const ignored = /node_modules|\.git|\.expo|android|ios|\.idea|__tests__|.ios\.js|.android\.js|\.web\.js|\.sh|\.iml|\.vs_code|alita\.config\.js|babel\.config\.js|metro\.config\.js|\.gitignore|app\.json|package\.json|package-lock\.json|\.eslintrc\.js|\.eslintrc\.json|\.eslintrc|yarn\.lock|\.test\.js|.watchmanconfig/
filewatch(ignored)
Expand Down
4 changes: 2 additions & 2 deletions src/util/geneWXPackageJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import fse from 'fs-extra'
/**
* 生成微信小程序package.json
*/
export default function geneWXPackageJSON() {
export default function geneWXPackageJSON(wxName) {
const {
INPUT_DIR,
configObj,
Expand All @@ -34,7 +34,7 @@ export default function geneWXPackageJSON() {
if (!pack.name) {
console.log('package.json文件缺少name字段'.warn)
}
newPack.name = pack.name
newPack.name = wxName || pack.name
newPack.version = pack.version || '1.0.0'

global.execArgs.packageName = pack.name || ''
Expand Down

0 comments on commit 42f66d1

Please sign in to comment.