forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
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 = { | ||
normalizePath | ||
normalizePath, | ||
installDepTips | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters