https://github.com/usulpro/read-pkg-workspace
parses yarn-workspace folder structure
https://github.com/usulpro/read-pkg-workspace
file find folder json matching nested npm package parse path relative-path resolve search structure workspace workspaces yarn yarn-packages yarn-workspaces yarnpkg
Last synced: 10 months ago
JSON representation
parses yarn-workspace folder structure
- Host: GitHub
- URL: https://github.com/usulpro/read-pkg-workspace
- Owner: usulpro
- License: mit
- Created: 2018-02-14T10:26:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-15T16:46:48.000Z (almost 8 years ago)
- Last Synced: 2024-04-27T04:21:55.952Z (almost 2 years ago)
- Topics: file, find, folder, json, matching, nested, npm, package, parse, path, relative-path, resolve, search, structure, workspace, workspaces, yarn, yarn-packages, yarn-workspaces, yarnpkg
- Language: JavaScript
- Homepage:
- Size: 181 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# read-pkg-workspace
> Read the closest two package.json files and checks if they are organized in a workspace
- Supports Yarn [workspaces](https://yarnpkg.com/en/docs/workspaces)
- Based on [read-pkg-up](https://github.com/sindresorhus/read-pkg-up)
## Install
```sh
npm i read-pkg-workspace --save
```
## Usage
```js
const readPkgWsp = require('read-pkg-up');
const dir = '.../yarn-workspace-folder/packages/package-A/src/...';
readPkgWsp({ cwd: dir })
.then(result => console.log(result))
```
```console
result:
{ package:
{ pkg:
{ name: 'celestabelleabethabelle',
description: 'the unicorn',
version: '1.0.0',
main: 'src/index.js',
license: 'MIT',
keywords: [Array],
optDependencies: [Object],
readme: 'ERROR: No README data found!',
_id: 'celestabelleabethabelle@1.0.0' },
path: '/home/usulpro/WebProjects/read-pkg-workspace/workspaces/unicorns/celestabelleabethabelle/package.json',
tailPath: 'src/stories',
relativePath: 'unicorns/celestabelleabethabelle' },
workspace:
{ pkg:
{ private: true,
workspaces: [Array],
name: '',
version: '',
readme: 'ERROR: No README data found!',
_id: '@' },
path: '/home/usulpro/WebProjects/read-pkg-workspace/workspaces/package.json',
name: 'workspaces' },
path: '/home/usulpro/WebProjects/read-pkg-workspace' }
```
Where
`result.package.pkg` - is result of `read-pkg-up` for `package.json` located in the project folder
`result.workspace.pkg` - is result of `read-pkg-up` for `package.json` located in the workspace root folder
`result.package.relativePath` - is the relative path from workspace folder to the project folder
`result.package.tailPath` - is the relative path from project folder to the specified in argument `cwd` folder
`result.workspace.name` - the name of workspace root folder
`result.path` - path to the folder that contain the workspace root folder
## This package is under development now