https://github.com/bernankez/npm-open
Open npm package homepage with `npm-open`, similar to `git-open`
https://github.com/bernankez/npm-open
Last synced: 5 months ago
JSON representation
Open npm package homepage with `npm-open`, similar to `git-open`
- Host: GitHub
- URL: https://github.com/bernankez/npm-open
- Owner: Bernankez
- License: mit
- Created: 2024-08-30T02:18:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T01:05:40.000Z (almost 2 years ago)
- Last Synced: 2025-02-19T10:02:51.135Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 93.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# npm-open
[](https://www.npmjs.com/package/@bernankez/npm-open)
[](https://github.com/Bernankez/npm-open/actions)
Type `npm-open` to open the npm package page in the browser. Similar to `git-open`.
## Install
```sh
pnpm add -g @bernankez/npm-open
```
## Usage
Run in the project root directory:
```sh
npm-open
```
You can also specify the root directory using the `--cwd` flag:
```sh
npm-open --cwd
```
By default, it opens page with your current npm registry. If you want to open the npm official package page, using the `-n` or `--npm`:
```sh
npm-open -n
```
## Config
`npm-open` suppports customizing npm registry config via `npmopen.config.ts`. You can customize the website page url.
```ts
// npmopen.config.ts
import { defineConfig } from "@bernankez/npm-open";
export default defineConfig({
// Always open npm package page or not
npm: false,
// Custom registry config
registry: [
{
name: "custom",
url: "https://your-custom-registry/",
website: pkgName => `https://your-custom-registry/page/${pkgName}`
}
]
});
```
## API Usage
```ts
import { resolvePackage } from "@bernankez/npm-open";
const pkgName = "@bernankez/npm-open";
async function load(): Promise {
const pkg = await resolvePackage(pkgName, {
npm: true,
});
console.log(pkg);
// {
// name: "npm",
// url: "https://registry.npmjs.org/@bernankez/npm-open",
// website: "https://www.npmjs.com/package/@bernankez/npm-open",
// }
}
load();
```
## License
[MIT](LICENSE) License © 2024-PRESENT [科科Cole](https://github.com/Bernankez)