Socket
Socket
Sign inDemoInstall

tinyexec

Package Overview
Dependencies
Maintainers
0
Versions
9
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


Version published
Weekly downloads
246K
increased by12.21%
Maintainers
0
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 25 Aug 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