has-lockfile
Detect lockfiles in the working directory
Useful for tools that need to know whether to use yarn
or npm
.
Installation
npm install --save has-lockfile
Usage
$ 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
const hasLockfile = ; ;// => false ;//=> true hasLockfile;//=> [] hasLockfile;//=> ['package-lock.json'] hasLockfile;//=> ['yarn.lock'] hasLockfile;//=> ['npm-shrinkwrap.json'] hasLockfile;//=> ['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 - Check if a
package-lock.json
is present in the working directory - has-shrinkwrap - Check if
npm-shrinkwrap.json
is present in the working directory - has-yarn - Check if a project is using Yarn
- pkg-man - Detect which package manager that should be used
License
MIT © Lufty Wiranda