https://github.com/lennetech/npm-package-helper
[lenne.Tech](https://github.com/lenneTech) helper for handling npm packages
https://github.com/lennetech/npm-package-helper
Last synced: about 1 year ago
JSON representation
[lenne.Tech](https://github.com/lenneTech) helper for handling npm packages
- Host: GitHub
- URL: https://github.com/lennetech/npm-package-helper
- Owner: lenneTech
- License: mit
- Created: 2019-09-01T06:45:40.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T15:57:49.000Z (over 3 years ago)
- Last Synced: 2025-05-22T21:12:14.538Z (about 1 year ago)
- Language: TypeScript
- Size: 414 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Npm package helper
[lenne.Tech](https://github.com/lenneTech) helper for handling npm packages.
For example, the versions of package.json and package-lock.json can be synchronized very easily.
[](/LICENSE) [](https://circleci.com/gh/lenneTech/npm-package-helper/tree/master)
[](https://david-dm.org/lenneTech/npm-package-helper) [](https://david-dm.org/lenneTech/npm-package-helper?type=dev)
## Installation
```
$ npm install --save-dev @lenne.tech/npm-package-helper
```
## Usage
After installing this package, the root directory of the project should contain the following script, which synchronizes the package.json and package-lock.json versions:
`extras/sync-version.ts`
```typescript
import NpmPackageHelper from '@lenne.tech/npm-package-helper';
import { join } from 'path';
// Sync version of package.json and package-lock.json
const run = () => {
// Init
const nph = NpmPackageHelper;
const dir = process.cwd();
// Set highest version
nph
.setHighestVersion([
nph.getFileData(join(dir, 'package-lock.json')),
nph.getFileData(join(dir, 'package.json'))
])
.then(version => {
// Log version
console.log(version);
});
};
run();
```
This script can be used by husky, for example:
`package.json`
```json5
{
// ...
husky: {
hooks: {
'pre-commit': 'ts-node extras/sync-version.ts && pretty-quick --staged',
'pre-push': 'npm run lint && npm run test'
}
}
// ...
}
```
## License
MIT - see LICENSE