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

shelljs-transpiler

v0.2.6

Published

Translate bash to shelljs

Downloads

37

Readme

shelljs-transpiler

Travis Codecov npm

"Say goodbye to those gnarly Bash scripts!" -- @arturadib, ShellJS README

Want to try out ShellJS but don't want to go through the effort of porting all your scripts? Look no further.

Easily transpile your Bash scripts to ShellJS. Try it out here on the web. Just type, copy-paste, or drag-and-drop your favorite shell script and see the results.

Have a lot of scripts to transpile? Install this globally to use sh2js to transpile scripts from the command line.

Think this is cool?

Let me know by giving it a star on Github.

Think this is really cool? :sunglasses:

Contributions would be awesome! I'd really like to propel this project forward, but don't have much time. You can help me out by:

  • sending me scripts you'd like to be able to translate, but haven't been able to
  • finding bugs or thinking of features
  • taking up one of the help-wanted issues
  • helping refactor the grammar so that other people can use it too.
  • spreading the word (more awareness = more contributors)

Installation

Note: this may not handle all Bash syntax until v1.0. If your script doesn't get translated successfully, please file a Github issue.

$ npm install -g shelljs-transpiler # this lets you use `sh2js`

ShellJS and NodeJS compatibility

What version of ShellJS is this compatible with? Can I run this code? Do I need a special version of Node? Will this translate anything correctly?

Your best bet are the latest versions of NodeJS and ShellJS. Some translations are significantly easier to do using ES6 features, so I use them where convenient. Also, ShellJS is still under development, so we're always adding new features to help give it the best of both JavaScript and Bash.

I'll sometimes write translations that take advantage of my not-yet-implemented ShellJS feature ideas--some of which may never get implemented. If your translated script relies on a feature that doesn't exist yet in ShellJS, let me know and I'll fix the transpiler to use a ShellJS feature that's available here and now.

sh2js CLI tool

The sh2js CLI transpiler is still somewhat experimental, but feel free to check it out! Usage:

$ sh2js [--plugins=<names>] <shell script input> [JavaScript output]

If you want to take advantage of shelljs plugins in the translated script, you're free to do so! Simply use the --plugins flag to supply a space-separated list of the plugins you want to use.

Ex. usage:

$ sh2js testFile.sh outputFile.js # overwrites outputFile.js
$ sh2js testFile.sh # writes to stdout
$ sh2js --plugins="tr open clear" testFile.sh # takes advantage of these plugins

Contributing

As stated above, contributions are welcome! If you're interested in helping out, let me know by posting an issue or shooting me an email.

Running the project

First, install it (and the git submodule dependencies!)

$ git clone --recursive https://github.com/nfischer/shelljs-transpiler.git
$ cd shelljs-transpiler/
$ npm install

Next, run it in the browser using npm start, run unit tests using npm test, or try a script with path/to/shelljs-transpiler/bin/sh2js someScript.sh.