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

@actions/exec

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@actions/exec

Actions exec lib

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created

What is @actions/exec?

@actions/exec is an npm package designed to facilitate the execution of shell commands within GitHub Actions workflows. It provides a simple and flexible API to run commands, capture their output, and handle errors.

What are @actions/exec's main functionalities?

Basic Command Execution

This feature allows you to execute basic shell commands. In this example, the 'echo' command is used to print 'Hello, world!' to the console.

const exec = require('@actions/exec');

async function run() {
  await exec.exec('echo', ['Hello, world!']);
}

run();

Capture Output

This feature allows you to capture the output and error streams of the executed command. In this example, the 'node -v' command is executed, and its output and error streams are captured and printed to the console.

const exec = require('@actions/exec');

async function run() {
  let myOutput = '';
  let myError = '';

  const options = {};
  options.listeners = {
    stdout: (data) => {
      myOutput += data.toString();
    },
    stderr: (data) => {
      myError += data.toString();
    }
  };

  await exec.exec('node', ['-v'], options);
  console.log('Output:', myOutput);
  console.log('Error:', myError);
}

run();

Command with Options

This feature allows you to execute commands with additional options such as the working directory and environment variables. In this example, the 'ls -la' command is executed in a specified working directory with a custom environment variable.

const exec = require('@actions/exec');

async function run() {
  const options = {
    cwd: '/path/to/working/directory',
    env: { MY_VAR: 'value' }
  };

  await exec.exec('ls', ['-la'], options);
}

run();

Other packages similar to @actions/exec

Keywords

FAQs

Package last updated on 17 Mar 2022

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