Socket
Socket
Sign inDemoInstall

@actions/exec

Package Overview
Dependencies
Maintainers
3
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


Version published
Weekly downloads
579K
increased by11.1%
Maintainers
3
Weekly downloads
 
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 28 Apr 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