Skip to content

Commit

Permalink
fix(alita): 修复 alita init 之后RN项目,无法直接启动的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ykforerlang committed Nov 4, 2019
1 parent 9a0023e commit 82a8d30
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/util/initProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

import path from 'path'
import fse from 'fs-extra'
import child_process from 'child_process'
import {successInfo} from './util'


export default function initProject(operands) {
console.log(`alita init ...`.info)
console.log('\n')
const initIndex = operands.indexOf('init')
const projectName = operands[initIndex + 1]

Expand All @@ -37,6 +41,23 @@ export default function initProject(operands) {
...packageObj.dependencies,
}
fse.outputJsonSync(pjsonPath, packageObj, {spaces: ' '})

if (fse.existsSync(path.resolve(targetpath, 'yarn.lock'))) {
child_process.execSync('yarn add @areslabs/router', {
cwd: targetpath,
})
child_process.execSync('yarn add @areslabs/wx-animated', {
cwd: targetpath,
})
} else {
child_process.execSync('npm install --save @areslabs/router', {
cwd: targetpath,
})
child_process.execSync('npm install --save @areslabs/wx-animated', {
cwd: targetpath,
})
}

console.log(' Run instructions for 小程序:'.blue)
console.log(` • alita -i ${projectName} -o [目标小程序目录] (若需要监听文件修改添加参数:--watch)`.black)
}

0 comments on commit 82a8d30

Please sign in to comment.