Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabiospampinato/get-current-package
Get the package.json of the currently executing bin.
https://github.com/fabiospampinato/get-current-package
cli current get package
Last synced: 19 days ago
JSON representation
Get the package.json of the currently executing bin.
- Host: GitHub
- URL: https://github.com/fabiospampinato/get-current-package
- Owner: fabiospampinato
- License: mit
- Created: 2023-02-09T20:20:33.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-24T16:28:48.000Z (about 1 year ago)
- Last Synced: 2024-11-10T05:11:47.930Z (about 1 month ago)
- Topics: cli, current, get, package
- Language: TypeScript
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Get Current Package
Get the `package.json` of the currently executing bin.
This is meant to be used in combination with [`tiny-updater`](https://github.com/fabiospampinato/tiny-updater) or similar, in order to get the name and the version of the currently executing bin very conveniently, without importing a "package.json" and without hard-coding the values yourself.
## Install
```sh
npm install --save get-current-package
```## Usage
You should have something like this in your bin app:
```ts
import getCurrentPackage from 'get-current-package';console.log ( getCurrentPackage () );
```Then executing the bin would produce this:
```
> my-bin
< { name: 'my-bin', version: '1.0.0', ... }
```Basically it detects which entrypoint file is being executed and retrieves its `package.json`.
## License
MIT © Fabio Spampinato