Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add pnpm v4 support #4677

Merged
merged 16 commits into from
Oct 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: reduce the amount of duplicate code for pnpm version check
  • Loading branch information
B4rtware committed Oct 11, 2019
commit e4e5617f50aeb59c9706e87719c0978b31b2a68e
34 changes: 15 additions & 19 deletions packages/@vue/cli-shared-utils/lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,7 @@ const _pnpmProjects = new LRU({
maxAge: 1000
})

exports.hasPnpm3OrLater = () => {
if (process.env.VUE_CLI_TEST) {
return true
}
if (_hasPnpm3orLater != null) {
return _hasPnpm3orLater
}
function checkPnpmVersion () {
try {
const pnpmVersion = execSync('pnpm --version', {
stdio: ['pipe', 'pipe', 'ignore']
Expand All @@ -102,29 +96,31 @@ exports.hasPnpm3OrLater = () => {
// so we only support pnpm >= 3.0.0
_hasPnpm = true
_hasPnpm3orLater = semver.gte(pnpmVersion, '3.0.0')
return _hasPnpm3orLater
_hasPnpm4orLater = semver.gte(pnpmVersion, '4.0.0')
return [_hasPnpm3orLater, _hasPnpm4orLater]
} catch (e) {
return (_hasPnpm3orLater = false)
return [_hasPnpm3orLater = false, _hasPnpm4orLater = false]
}
}

exports.hasPnpm3OrLater = () => {
if (process.env.VUE_CLI_TEST) {
return true
}
if (_hasPnpm3orLater != null) {
B4rtware marked this conversation as resolved.
Show resolved Hide resolved
return _hasPnpm3orLater
}
return checkPnpmVersion()[0]
B4rtware marked this conversation as resolved.
Show resolved Hide resolved
}

exports.hasPnpm4OrLater = () => {
if (process.env.VUE_CLI_TEST) {
return true
}
if (_hasPnpm4orLater != null) {
return _hasPnpm4orLater
}
try {
const pnpmVersion = execSync('pnpm --version', {
stdio: ['pipe', 'pipe', 'ignore']
}).toString()
_hasPnpm = true
_hasPnpm4orLater = semver.gte(pnpmVersion, '4.0.0')
return _hasPnpm4orLater
} catch (e) {
return (_hasPnpm4orLater = false)
}
return checkPnpmVersion()[1]
B4rtware marked this conversation as resolved.
Show resolved Hide resolved
}

exports.hasProjectPnpm = (cwd) => {
Expand Down