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

mvdan-sh

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mvdan-sh

A shell parser and formatter (POSIX/Bash/mksh)

  • 0.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
178K
decreased by-6.58%
Maintainers
1
Weekly downloads
 
Created
Source

mvdan-sh

This package is a JavaScript version of a shell package written in Go, available at https://github.com/mvdan/sh.

It is transpiled from Go to JS using GopherJS, available at https://github.com/gopherjs/gopherjs

Here is a simple usage example:

const sh = require('mvdan-sh')
const syntax = sh.syntax

var parser = syntax.NewParser()
var printer = syntax.NewPrinter()

var src = "echo 'foo'"
var f = parser.Parse(src, "src.js")

// print out the syntax tree
syntax.DebugPrint(f)
console.log()

// replace all single quoted string values
syntax.Walk(f, function(node) {
        if (syntax.NodeType(node) == "SglQuoted") {
                node.Value = "bar"
        }
        return true
})

// print the code back out
console.log(printer.Print(f)) // echo 'bar'

Keywords

FAQs

Package last updated on 26 Apr 2018

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