Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yarnpkg/core

Package Overview
Dependencies
Maintainers
6
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/core

  • 3.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
346K
decreased by-5.13%
Maintainers
6
Weekly downloads
 
Created

What is @yarnpkg/core?

@yarnpkg/core is a core library for the Yarn package manager, providing essential functionalities for managing dependencies, workspaces, and scripts in JavaScript projects. It allows developers to programmatically interact with Yarn's features, making it easier to automate and customize package management tasks.

What are @yarnpkg/core's main functionalities?

Dependency Management

This code demonstrates how to programmatically install dependencies for a project using @yarnpkg/core. It initializes the configuration and project, then calls the install method to install the dependencies.

const { Configuration, Project } = require('@yarnpkg/core');
const { npath } = require('@yarnpkg/fslib');

(async () => {
  const configuration = await Configuration.find(npath.toPortablePath(__dirname), null, {
    useRc: false,
  });
  const { project } = await Project.find(configuration, npath.toPortablePath(__dirname));
  await project.install();
})();

Workspace Management

This code demonstrates how to list all workspaces in a project using @yarnpkg/core. It initializes the configuration and project, then iterates over the workspaces to log their paths.

const { Configuration, Project } = require('@yarnpkg/core');
const { npath } = require('@yarnpkg/fslib');

(async () => {
  const configuration = await Configuration.find(npath.toPortablePath(__dirname), null, {
    useRc: false,
  });
  const { project } = await Project.find(configuration, npath.toPortablePath(__dirname));
  const workspaces = project.workspaces;
  workspaces.forEach(workspace => {
    console.log(`Workspace: ${workspace.cwd}`);
  });
})();

Script Execution

This code demonstrates how to execute a script in a workspace using @yarnpkg/core. It initializes the configuration and project, retrieves the workspace, and then executes the 'build' script.

const { Configuration, Project, scriptUtils } = require('@yarnpkg/core');
const { npath } = require('@yarnpkg/fslib');

(async () => {
  const configuration = await Configuration.find(npath.toPortablePath(__dirname), null, {
    useRc: false,
  });
  const { project } = await Project.find(configuration, npath.toPortablePath(__dirname));
  const workspace = project.getWorkspaceByCwd(npath.toPortablePath(__dirname));
  await scriptUtils.executeWorkspaceScript(workspace, 'build', []);
})();

Other packages similar to @yarnpkg/core

FAQs

Package last updated on 16 Mar 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc