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

feat: support cnpm #8

Merged
merged 2 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ If you want to force [npm](https://docs.npmjs.com/cli/npm), add:
}
```

If you want to force [cnpm](https://npmmirror.com/), add:

```json
{
"scripts": {
"preinstall": "npx only-allow cnpm"
}
}
```

If you want to force [pnpm](https://pnpm.js.org/), add:

```json
Expand Down
9 changes: 6 additions & 3 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const boxen = require('boxen')

const argv = process.argv.slice(2)
if (argv.length === 0) {
console.log('Please specify the wanted package manager: only-allow <npm|pnpm|yarn>')
console.log('Please specify the wanted package manager: only-allow <npm|cnpm|pnpm|yarn>')
process.exit(1)
}
const wantedPM = argv[0]
if (wantedPM !== 'npm' && wantedPM !== 'pnpm' && wantedPM !== 'yarn') {
console.log(`"${wantedPM}" is not a valid package manager. Available package managers are: npm, pnpm, or yarn.`)
if (wantedPM !== 'npm' && wantedPM !== 'cnpm' && wantedPM !== 'pnpm' && wantedPM !== 'yarn') {
console.log(`"${wantedPM}" is not a valid package manager. Available package managers are: npm, cnpm, pnpm, or yarn.`)
process.exit(1)
}
const usedPM = whichPMRuns()
Expand All @@ -19,6 +19,9 @@ if (usedPM && usedPM.name !== wantedPM) {
case 'npm':
console.log(boxen('Use "npm install" for installation in this project', boxenOpts))
break
case 'cnpm':
console.log(boxen('Use "cnpm install" for installation in this project', boxenOpts))
break
case 'pnpm':
console.log(boxen(`Use "pnpm install" for installation in this project.

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"scripts": {},
"keywords": [
"pnpm",
"cnpm",
"npm",
"yarn"
],
Expand All @@ -25,6 +26,6 @@
"homepage": "https://github.com/pnpm/only-allow#readme",
"dependencies": {
"boxen": "^4.2.0",
"which-pm-runs": "^1.0.0"
"which-pm-runs": "^1.1.0"
}
}
173 changes: 79 additions & 94 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.