Socket
Socket
Sign inDemoInstall

pkgu

Package Overview
Dependencies
34
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pkgu

Yarn Workspaces package utils.


Version published
Weekly downloads
6
increased by100%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

pkgu npm

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()
)
// Set(2) { '/…/packages/bar', '/…/packages/baz' }

console.log(
  await getPackages()
)
// Map(2) {
//   'bar' => {
//     dir: '/…/packages/bar',
//     json: {
//       name: 'bar',
//       version: '1.0.0'
//     }
//   },
//   'baz' => {
//     dir: '/…/packages/baz',
//     json: {
//       name: 'baz',
//       version: '2.0.0'
//     }
//   },
// }

console.log(
  await readPackageJson('/…/packages/bar') 
)
// {
//   name: 'bar',
//   version: '1.0.0'
// }

await writePackageJson('/…/packages/bar', { name: 'foo' }) 

console.log(
  await readPackageJson('/…/packages/bar') 
)
// { name: 'foo' }

FAQs

Last updated on 28 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc