jalal246 / corename

Automatically extracts packages root name for monorepos

Home Page:https://jalal246.github.io/corename/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

corename

Extracts the name of monorepo project

npm install corename

API

getCoreName

getCoreName(pkgJson: Array<pkgJsonObj>|Object)

Usage

import getCoreName from "corename";

const pkg0 = {
  name: "pkg-first",
  dependencies: {},
};

const pkg1 = {
  name: "@pkg-second",
  dependencies: {
    "@pkg/first": "^0.1.5",
  },
};

const pkg2 = {
  name: "@pkg/third",
  dependencies: {},
};

const name = getCoreName([pkg0, pkg1, pkg2]);

// name = "@pkg";

Or just pass a single package

const name = getCoreName(pkg2);

// name = "@pkg";

In case there's no matching pattern, it returns null:

const name = getCoreName(pkg1);

// name = null;

Or tell it to return the exact name found in package.json

const returnNameIfMonoNotFound = true;

const name = getCoreName(pkg1, returnNameIfMonoNotFound);

// name = "@pkg-second";

Tests

npm test

License

This project is licensed under the GPL-3.0 License

Related projects

  • builderz - JavaScript Bundler with zero configuration.

  • packageSorter - Sorting packages for monorepos production.

  • get-info - Utility functions for projects production

  • move-position - Moves element index in an array.

  • textics & textics-stream - Counts lines, words, chars and spaces for a given string.

  • folo - Form & Layout Components Built with React.

About

Automatically extracts packages root name for monorepos

https://jalal246.github.io/corename/

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%