🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
52
node_modules/preferred-pm/index.js
generated
vendored
Normal file
52
node_modules/preferred-pm/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
'use strict'
|
||||
const findYarnWorkspaceRoot = require('find-yarn-workspace-root2')
|
||||
const findUp = require('find-up')
|
||||
const path = require('path')
|
||||
const pathExists = require('path-exists')
|
||||
const whichPM = require('which-pm')
|
||||
|
||||
module.exports = async function preferredPM (pkgPath) {
|
||||
if (typeof pkgPath !== 'string') {
|
||||
throw new TypeError(`pkgPath should be a string, got ${typeof pkgPath}`)
|
||||
}
|
||||
if (await pathExists(path.join(pkgPath, 'package-lock.json'))) {
|
||||
return {
|
||||
name: 'npm',
|
||||
version: '>=5'
|
||||
}
|
||||
}
|
||||
if (await pathExists(path.join(pkgPath, 'yarn.lock'))) {
|
||||
return {
|
||||
name: 'yarn',
|
||||
version: '*'
|
||||
}
|
||||
}
|
||||
if (await pathExists(path.join(pkgPath, 'pnpm-lock.yaml'))) {
|
||||
return {
|
||||
name: 'pnpm',
|
||||
version: '>=3'
|
||||
}
|
||||
}
|
||||
if (await pathExists(path.join(pkgPath, 'shrinkwrap.yaml'))) {
|
||||
return {
|
||||
name: 'pnpm',
|
||||
version: '1 || 2'
|
||||
}
|
||||
}
|
||||
if (await findUp('pnpm-lock.yaml', { cwd: pkgPath })) {
|
||||
return {
|
||||
name: 'pnpm',
|
||||
version: '>=3'
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (typeof findYarnWorkspaceRoot(pkgPath) === 'string') {
|
||||
return {
|
||||
name: 'yarn',
|
||||
version: '*'
|
||||
}
|
||||
}
|
||||
} catch (err) {}
|
||||
const pm = await whichPM(pkgPath)
|
||||
return pm && { name: pm.name, version: pm.version || '*' }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue