npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@seung_h/node-sh

v1.2.1

Published

Portable implementations and executions of bash commands for node.js

Downloads

2

Readme

banner

nodejs typescript license

Node-sh is a bash command implementation and os shell command execution for node.js that runs on mac os, linux and windows. It makes you easier to execute your os shell commands. implement bash commands and functionalize it.

🕹 Install

 $ yarn add node-sh
 $ npm install node-sh

🔥 Features

  • TypeScript based, zero dependencies. 📦
  • Simple command execution with user environment.
  • 23 bash commands implemented.
  • Each command supports type-based JavaScript API and pipe commands.
  • Provides details about exceptions in user command with rendered code.

📌 Import

If the $ namespace conflicts, you can use named import rather than global import.

 import 'node-sh' // $.commands
 import bash from 'node-sh' // bash.commands

📝 Commands

Designed to be easy to use, node-sh uses only one interface. it can execute commands and implementations.

🔐 Execute

  const exec = $ `ls -al | grep 'node-sh'`

Caution: This function uses the child process module to execute commands directly.

Environments

 $.env: {
     verbose    : boolean           = false
     prefix     : string            = ''
     shell      : string | boolean  = true
     max_buffer : number            = 200 * 1024 * 1024
 } // structures
 
 $.env.shell = $.which `git`

💡 Implement

Node-sh has implemented syntax and options, etc. similar to bash based on linux man page to improve the user-experience.

🔗 UnixExtension

Each function (except void functions) returns stdout to UnixExtension class that can use JavaScript API according to the type of stdout or pipe functions such as grep, sort, uniq, etc.

📖 Check the module has a default export.

 import 'node-sh'
 
 const output = $.cat `src/test.ts`.includes('export default')

📖 Get only directories.

 import 'node-sh'
   
 // Use JavaScript API
 const api = $.ls `-al`.filter(data => data.startsWith('d'))
   
 // Use UnixExtension
 const extension = $.ls `-al`.grep `^d`

🛠 Exceptions

Node-sh provides detail of the exceptions that occurred in user commands or internal and suggests solutions for them.

Note: It is only used for errors handled within the module and cannot be used externally.

exception

📋 License

Distributed under the MIT License. See LICENSE for more information.