4.0.0 • Published 10 months ago

@wixc3/resolve-directory-context v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@wixc3/resolve-directory-context

Build Status npm version

Helpers to get information about single/multi-package contexts.

Features

Supports:

  • single packages
  • "workspaces" in package.json (yarn or npm@7)
  • lerna.json defined workspaces

API

  • resolveDirectoryContext
import fs from 'fs';
import path from 'path';
import { resolveDirectoryContext } from '@wixc3/resolve-directory-context';

const context = resolveDirectoryContext(basePath, { ...fs, ...path });
if (context.type === 'multi') {
  // context.rootPackage === {...}
  // context.packages === [{...}, {...}]
} else {
  // context.type === 'single'
  // context.npmPackage === {...}
}

License

MIT