0.0.12 • Published 2 years ago

@lenne.tech/npm-package-helper v0.0.12

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

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

0.0.11

2 years ago

0.0.12

2 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago