Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luftywiranda13/has-lockfile
Detect lockfiles in the working directory
https://github.com/luftywiranda13/has-lockfile
check detect find lock-file lockfile npm npm-shrinkwrap package-lock package-lock-json yarn yarn-lock
Last synced: 2 months ago
JSON representation
Detect lockfiles in the working directory
- Host: GitHub
- URL: https://github.com/luftywiranda13/has-lockfile
- Owner: luftywiranda13
- License: mit
- Created: 2017-08-11T10:39:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:19:57.000Z (over 4 years ago)
- Last Synced: 2024-11-11T10:57:14.720Z (3 months ago)
- Topics: check, detect, find, lock-file, lockfile, npm, npm-shrinkwrap, package-lock, package-lock-json, yarn, yarn-lock
- Language: JavaScript
- Homepage:
- Size: 286 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# has-lockfile
> Detect lockfiles in the working directory
[![Package Version](https://img.shields.io/npm/v/has-lockfile.svg?style=flat-square)](https://www.npmjs.com/package/has-lockfile)
[![Downloads Status](https://img.shields.io/npm/dm/has-lockfile.svg?style=flat-square)](https://npm-stat.com/charts.html?package=has-lockfile&from=2016-04-01)
[![Build Status: Linux](https://img.shields.io/travis/luftywiranda13/has-lockfile/master.svg?style=flat-square)](https://travis-ci.org/luftywiranda13/has-lockfile)
[![Coverage Status](https://img.shields.io/codecov/c/github/luftywiranda13/has-lockfile/master.svg?style=flat-square)](https://codecov.io/gh/luftywiranda13/has-lockfile)Useful for tools that need to know whether to use `yarn` or `npm`.
## Installation
```sh
npm install has-lockfile
```## Usage
```sh
$ tree
.
├── bar
│ ├── package-lock.json
│ └── package.json
├── baz
│ ├── package.json
│ └── yarn.lock
├── foo
│ ├── npm-shrinkwrap.json
│ └── package.json
├── qux
│ ├── npm-shrinkwrap.json
│ ├── package-lock.json
│ ├── package.json
│ └── yarn.lock
└── package.json
``````js
const hasLockfile = require('has-lockfile');hasLockfile();
// => falsehasLockfile('bar');
//=> truehasLockfile.lockfiles();
//=> []hasLockfile.lockfiles('bar');
//=> ['package-lock.json']hasLockfile.lockfiles('baz');
//=> ['yarn.lock']hasLockfile.lockfiles('foo');
//=> ['npm-shrinkwrap.json']hasLockfile.lockfiles('qux');
//=> ['package-lock.json', 'yarn.lock', 'npm-shrinkwrap.json']
```## API
### hasLockfile([cwd])
Returns `boolean`.
### hasLockfile.lockfiles([cwd])
Returns `Array` of lockfiles.
#### cwd
Type: `string`
Default: `process.cwd()`Current working directory.
## Related
* [has-package-lock](https://github.com/luftywiranda13/has-package-lock) - Check if a `package-lock.json` is present in the working directory
* [has-shrinkwrap](https://github.com/luftywiranda13/has-shrinkwrap) - Check if `npm-shrinkwrap.json` is present in the working directory
* [has-yarn](https://github.com/sindresorhus/has-yarn) - Check if a project is using Yarn
* [pkg-man](https://github.com/luftywiranda13/pkg-man) - Detect which package manager that should be used## License
MIT © [Lufty Wiranda](https://www.luftywiranda.com)