pkgu
Yarn Workspaces package utils.
Install
$ yarn add pkgu
Usage
type TPackageJson = {
name: string,
version: string,
}
type TPackages = Map<string, {
dir: string,
json: TPackageJson
}>
const getPackageDirs: () => Promise<Set<string>>
const getPackages: () => Promise<TPackages>
const readPackageJson: (packageDir: string) => Promise<TPackageJson>
const writePackageJson: (packageDir: string, packageJson: TPackageJson) => Promise<void>
import { getPackageDirs, getPackages, readPackageJson, writePackageJson } from 'pkgu'
console.log(
await getPackageDirs()
)
console.log(
await getPackages()
)
console.log(
await readPackageJson('/…/packages/bar')
)
await writePackageJson('/…/packages/bar', { name: 'foo' })
console.log(
await readPackageJson('/…/packages/bar')
)