https://github.com/ifiokjr/get-installer
Get the installer used (pnpm, yarn or npm), for a particular root directory
https://github.com/ifiokjr/get-installer
Last synced: 4 months ago
JSON representation
Get the installer used (pnpm, yarn or npm), for a particular root directory
- Host: GitHub
- URL: https://github.com/ifiokjr/get-installer
- Owner: ifiokjr
- License: mit
- Created: 2020-03-17T13:20:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T16:29:18.000Z (over 2 years ago)
- Last Synced: 2025-01-14T10:57:20.688Z (5 months ago)
- Language: TypeScript
- Size: 3.59 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# get-installer
[](#contributors-)
[](https://github.com/ifiokjr/get-installer/actions?query=workflow%3A%22Node+CI%22)
[![Version][version]][npm]
[![Weekly Downloads][downloads-badge]][npm]
[![Typed Codebase][typescript]](./src/index.ts)
![MIT License][license]
[](https://github.com/semantic-release/semantic-release)
> Get the type of the installer that is used at the directory provided whether `npm`, `yarn` or `pnpm`. Open to PR's for other options.
## Table of Contents
- [get-installer](#get-installer)
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Setup](#setup)
- [Code Example](#code-example)
- [API](#api)
- [`InstallerType`](#installertype)
- [`getInstaller`](#getinstaller)
- [Returns](#returns)
- [`getInstallerSync`](#getinstallersync)
- [Returns](#returns-1)
- [Contributing](#contributing)
- [Versioning](#versioning)
- [License](#license)
- [Contributors](#contributors)
## Usage
`get-installer` is designed to be used inside your node project.
### Setup
First, install the plugin and it's peer dependencies:
```bash
npm install --save get-installer
```or
```bash
yarn add get-installer
```
### Code Example
The following will return the type of installer that is active at the given directory.
```ts
import { getInstallerSync } from 'get-installer';const installer = getInstallerSync('/path/to/project');
```The async method can also be used.
```ts
import { getInstaller } from 'get-installer';const installer = await getInstaller('/path/to/project');
```
## API
### `InstallerType`
```ts
import { InstallerType } from 'get-installer';
```The currently supported installers are `'yarn'`, `'npm'` and `'pnpm'`.
### `getInstaller`
```ts
import { getInstaller } from 'get-installer';
```#### Returns
Returns a promise resolving to the `InstallerType`. Defaults to `'npm'` if it can't properly be resolved.
### `getInstallerSync`
```ts
import { getInstallerSync } from 'get-installer';
```#### Returns
Returns the `InstallerType`. Defaults to `'npm'` if it can't properly be resolved.
## Contributing
Dive into the codebase with Gitpod.
[](https://gitpod.io/#https://github.com/ifiokjr/get-installer)
## Versioning
This project uses [SemVer](http://semver.org/) for versioning. For the versions available, see the
[tags on this repository](https://github.com/ifiokjr/get-installer/tags).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
## Contributors
[version]: https://flat.badgen.net/npm/v/get-installer
[npm]: https://npmjs.com/package/get-installer
[license]: https://flat.badgen.net/badge/license/MIT/purple
[size]: https://bundlephobia.com/result?p=#get-installer
[size-badge]: https://flat.badgen.net/bundlephobia/minzip/get-installer
[typescript]: https://flat.badgen.net/badge/icon/TypeScript/?icon=typescript&label&labelColor=blue&color=555555
[downloads-badge]: https://badgen.net/npm/dw/get-installer/red?icon=npm