0.1.10 • Published 4 years ago

@guijs/get-workspaces v0.1.10

Weekly downloads
26
License
MIT
Repository
github
Last release
4 years ago

Get Workspaces

A simple utility to get workspaces, whether they be yarn or bolt.

Forked from atlassian/changesets

This library exports a very simple function that looks at a package.json, and generates the glob of accepted workspaces from the workspaces field. It is intended mostly for use of developers building tools that want to support both kinds of mono-repos as an easy way to write tools for both.

import getWorkspaces from '@guijs/get-workspaces'

const workspaces = await getWorkspaces()

Workspaces have the shape:

{
    name // The name from the package.json
    config // The package.json of the package
    dir // The directory of the package
}

Config

We assume the function is being run from a directory with the package.json you want to target, however you can pass in a working directory if you want. In addition, you can change what tools the package will scan for.

const workspaces = await getWorkspaces({ cwd, tools })

The tools supported are yarn, bolt, lerna, and root, which returns the root package as a single workspace if passed. Tools is an array, so you can try for one type of workspace and then another, so you could do:

getWorkspaces({ tools: ['bolt', 'yarn', 'lerna', 'root'] })
0.1.10

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago