Skip to content

Commit 82a8d30

Browse files
committedNov 4, 2019
fix(alita): 修复 alita init 之后RN项目,无法直接启动的bug
1 parent 9a0023e commit 82a8d30

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎src/util/initProject.js

+21
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88

99
import path from 'path'
1010
import fse from 'fs-extra'
11+
import child_process from 'child_process'
1112
import {successInfo} from './util'
1213

14+
1315
export default function initProject(operands) {
16+
console.log(`alita init ...`.info)
17+
console.log('\n')
1418
const initIndex = operands.indexOf('init')
1519
const projectName = operands[initIndex + 1]
1620

@@ -37,6 +41,23 @@ export default function initProject(operands) {
3741
...packageObj.dependencies,
3842
}
3943
fse.outputJsonSync(pjsonPath, packageObj, {spaces: ' '})
44+
45+
if (fse.existsSync(path.resolve(targetpath, 'yarn.lock'))) {
46+
child_process.execSync('yarn add @areslabs/router', {
47+
cwd: targetpath,
48+
})
49+
child_process.execSync('yarn add @areslabs/wx-animated', {
50+
cwd: targetpath,
51+
})
52+
} else {
53+
child_process.execSync('npm install --save @areslabs/router', {
54+
cwd: targetpath,
55+
})
56+
child_process.execSync('npm install --save @areslabs/wx-animated', {
57+
cwd: targetpath,
58+
})
59+
}
60+
4061
console.log(' Run instructions for 小程序:'.blue)
4162
console.log(` • alita -i ${projectName} -o [目标小程序目录] (若需要监听文件修改添加参数:--watch)`.black)
4263
}

0 commit comments

Comments
 (0)