You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
817 B
38 lines
817 B
const fs = require('fs')
|
|
const path = require('path')
|
|
const {
|
|
normalizePath
|
|
} = require('../util')
|
|
|
|
function hasProjectYarn (cwd) {
|
|
return fs.existsSync(path.join(cwd, 'yarn.lock'))
|
|
}
|
|
|
|
function hasProjectPnpm (cwd) {
|
|
return fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))
|
|
}
|
|
|
|
function getInstallCommand (cwd) {
|
|
return hasProjectYarn(cwd)
|
|
? 'yarn add'
|
|
: hasProjectPnpm(cwd)
|
|
? 'pnpm i'
|
|
: 'npm i'
|
|
}
|
|
|
|
function installDepTips (
|
|
type,
|
|
module,
|
|
version
|
|
) {
|
|
const command =
|
|
`${getInstallCommand(process.cwd())} ${module + (version ? '@' + version : '')}${type === 'devDependencies' ? ' -D' : ''}`
|
|
return `Cannot find module: ${module}
|
|
Please run \`${command}\` and try again.`
|
|
}
|
|
|
|
module.exports = {
|
|
version: require('../../package.json').version,
|
|
normalizePath,
|
|
installDepTips
|
|
}
|
|
|