pkg-from-path
v1.1.2
Published
Automatically detects which package a given path belongs to.
Downloads
147
Readme
Install
npm add --save-dev pkg-from-path # Npm
yarn add -D pkg-from-path # Yarn
pnpm add -D pkg-from-path # Pnpm
Usage
import resolvePackagePath from 'pkg-from-path';
const path = resolvePackagePath('/workspace/project/node_modules/@eslint/js/src/configs/eslint-recommended.js');
/**
* return value:
{
"packageName": "@eslint/js",
"packageVersion": "9.15.0",
"relativePath": "src/configs/eslint-recommended.js",
"packageJsonPath": "P/workspace/project/node_modules/@eslint/js/package.json"
}
*/
console.log(JSON.stringify(path));