@bernankez/npm-open
v0.0.3
Published
Open npm package homepage with `npm-open`, similar to `git-open`
Downloads
5
Readme
npm-open
Type npm-open
to open the npm package page in the browser. Similar to git-open
.
Install
pnpm add -g @bernankez/npm-open
Usage
Run in the project root directory:
npm-open
You can also specify the root directory using the --cwd
flag:
npm-open --cwd <path to project>
By default, it opens page with your current npm registry. If you want to open the npm package page, using the -n
or --npm
:
npm-open -n
Config
npm-open
suppports customizing npm registry config via npmopen.config.ts
. You can customize the website page url.
// 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
import { resolvePackage } from "@bernankez/npm-open";
const pkgName = "@bernankez/npm-open";
async function load(): Promise<void> {
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();