Files
vue-cli/packages/@vue/cli-upgrade/get-package-json.js
Haoqun Jiang 77448897d4 feat: implement vue upgrade (#2428)
* feat: add vue upgrade command

* feat: implement vue upgrade
2018-10-31 01:07:39 +08:00

22 lines
476 B
JavaScript

const fs = require('fs')
const path = require('path')
module.exports = function getPackageJson (projectPath) {
const packagePath = path.join(projectPath, 'package.json')
let packageJson
try {
packageJson = fs.readFileSync(packagePath, 'utf-8')
} catch (err) {
throw new Error(`${packagePath} not exist`)
}
try {
packageJson = JSON.parse(packageJson)
} catch (err) {
throw new Error('The package.json is malformed')
}
return packageJson
}