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

@npmcli/run-script

Package Overview
Dependencies
Maintainers
6
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@npmcli/run-script

Run a lifecycle script for a package (descendant of npm-lifecycle)

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
6
Weekly downloads
 
Created

What is @npmcli/run-script?

The @npmcli/run-script package is a utility that allows you to execute npm package scripts programmatically. It is part of the npm CLI and is used internally to handle the 'npm run' command. This package provides an API for running scripts defined in a package.json file, including lifecycle scripts and custom user-defined scripts.

What are @npmcli/run-script's main functionalities?

Executing npm lifecycle scripts

This feature allows you to execute standard npm lifecycle scripts such as 'start', 'test', 'prepublish', etc., that are defined in a package.json file.

const runScript = require('@npmcli/run-script');

runScript({
  event: 'start',
  path: '/path/to/package',
  stdio: 'inherit'
}).then(() => {
  console.log('Lifecycle script executed successfully.');
}).catch((err) => {
  console.error('Error executing lifecycle script:', err);
});

Running custom scripts

This feature allows you to run custom scripts defined in the scripts section of a package.json file.

const runScript = require('@npmcli/run-script');

runScript({
  event: 'custom-script',
  path: '/path/to/package',
  stdio: 'inherit'
}).then(() => {
  console.log('Custom script executed successfully.');
}).catch((err) => {
  console.error('Error executing custom script:', err);
});

Passing arguments to scripts

This feature allows you to pass arguments to the scripts being executed, similar to how you would use 'npm run test -- --coverage' in the command line.

const runScript = require('@npmcli/run-script');

runScript({
  event: 'test',
  args: ['--coverage'],
  path: '/path/to/package',
  stdio: 'inherit'
}).then(() => {
  console.log('Test script executed with coverage.');
}).catch((err) => {
  console.error('Error executing test script with coverage:', err);
});

Other packages similar to @npmcli/run-script

FAQs

Package last updated on 30 Jul 2020

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