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

tinyexec

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinyexec

A minimal library for executing processes in Node

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.9M
increased by4.22%
Maintainers
1
Weekly downloads
 
Created

What is tinyexec?

The tinyexec npm package is a lightweight utility for executing shell commands in Node.js. It provides a simple and efficient way to run shell commands and capture their output, making it useful for scripting and automation tasks.

What are tinyexec's main functionalities?

Execute a simple command

This feature allows you to execute a simple shell command and capture its output. In this example, the 'echo' command is used to print 'Hello, World!' to the console.

const tinyexec = require('tinyexec');

(async () => {
  const result = await tinyexec('echo Hello, World!');
  console.log(result.stdout); // Outputs: Hello, World!
})();

Capture standard error

This feature allows you to capture the standard error output of a command. In this example, an attempt to run a nonexistent command results in an error, which is then captured and printed to the console.

const tinyexec = require('tinyexec');

(async () => {
  try {
    await tinyexec('nonexistent-command');
  } catch (error) {
    console.error(error.stderr); // Outputs the error message
  }
})();

Run a command with options

This feature allows you to run a command with additional options, such as specifying the working directory. In this example, the 'ls' command lists the files in the specified directory.

const tinyexec = require('tinyexec');

(async () => {
  const result = await tinyexec('ls', { cwd: '/path/to/directory' });
  console.log(result.stdout); // Outputs the list of files in the specified directory
})();

Other packages similar to tinyexec

Keywords

FAQs

Package last updated on 16 Oct 2024

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