UNPKG

1.01 kBJavaScriptView Raw
1const install = require('../utils/install')
2const getSpinner = require('../utils/getSpinner')
3const { isFireProject } = require('../utils/fire')
4const { warning, success } = require('../utils/tip')
5const { __pkgJson } = require('../utils/paths')
6const fs = require('fs-extra')
7const { shell } = require('execa')
8module.exports = async function() {
9 if (!isFireProject()) {
10 return warning(
11 'This is not a fire project,you can use fire init the project'
12 )
13 }
14 const updateSpinner = getSpinner('updating...')
15 updateSpinner.start()
16 try {
17 const { stdout } = await shell('npm view fire-scripts version')
18 const pkgJson = require(__pkgJson)
19 if (!pkgJson.dependencies) {
20 pkgJson.dependencies = {}
21 }
22 pkgJson.dependencies['fire-scripts'] = stdout
23 await fs.writeFile(__pkgJson, JSON.stringify(pkgJson, null, 2))
24 await install()
25 updateSpinner.stop()
26 success('\n √ update completed!')
27 } catch (e) {
28 console.log(e)
29 }
30}