@lenne.tech/npm-package-helper
TypeScript icon, indicating that this package has built-in type declarations

0.0.12 • Public • Published

Npm package helper

lenne.Tech helper for handling npm packages.

For example, the versions of package.json and package-lock.json can be synchronized very easily.

License CircleCI Dependency Status devDependency Status

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

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

{
  // ...
  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

Package Sidebar

Install

npm i @lenne.tech/npm-package-helper

Homepage

lenne.tech

Weekly Downloads

31

Version

0.0.12

License

MIT

Unpacked Size

28.5 kB

Total Files

20

Last publish

Collaborators

  • kai.haase
  • pascal.klesse