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

@tehshrike/shell-escape-tag

v1.2.2

Published

shell-escape-tag, but with a much smaller install size

Downloads

150

Readme

@tehshrike/shell-escape-tag

shell-escape-tag, but with a much smaller install size

An ES6 template tag which escapes parameters for interpolation into shell commands

INSTALL

$ npm install shell-escape-tag

SYNOPSIS

import shell from 'shell-escape-tag'

let filenames = glob('Holiday Snaps/*.jpg')
let title     = 'Holiday Snaps'
let command   = shell`compress --title ${title} ${filenames}`

console.log(command) // compress --title 'Holiday Snaps' 'Holiday Snaps/Pic 1.jpg' 'Holiday Snaps/Pic 2.jpg'

DESCRIPTION

This module exports an ES6 tagged-template function which escapes (i.e. quotes) its parameters for safe inclusion in shell commands. Parameters can be strings, arrays of strings, or nested arrays of strings, arrays and already-processed parameters.

The exported function also provides two helper functions which respectively escape and preserve their parameters and protect them from further processing.

EXPORTS

shell (default)

Signature: template: string → command: string

let filenames = [ 'foo bar', "baz's quux" ]
let title     = 'My Title'
let command   = shell`command --title ${title} ${filenames}`

console.log(command) // command --title 'My Title' 'foo bar' 'baz'"'"'s quux'

Takes a template literal and escapes any interpolated parameters. null and undefined values are ignored. Arrays are flattened and their elements are escaped and joined with a space. All other values are stringified i.e. false is mapped to "false" etc. Parameters that have been escaped with shell.escape or preserved with shell.preserve are passed through verbatim.

Functions

escape

Signature: ...any → Object

let params   = [ 'foo bar', "baz's quux" ]
let command1 = shell.escape('command', params)
let command2 = shell`command ${params}`

console.log(command1) // command 'foo bar' 'baz'"'"'s quux'
console.log(command2) // command 'foo bar' 'baz'"'"'s quux'

Flattens, compacts and escapes any parameters which haven't already been escaped or preserved, joins the resulting elements with a space, and wraps the resulting string in an object which is passed through verbatim when passed as a direct or nested parameter to shell, shell.escape, or shell.preserve.

preserve

Aliases: protect, verbatim

Signature: ...any → Object

let params   = [ 'foo bar', shell.preserve("baz's quux") ]
let command1 = shell.escape('command', params)
let command2 = shell`command ${params}`

console.log(command1) // command 'foo bar' baz's quux
console.log(command2) // command 'foo bar' baz's quux

Flattens, compacts and preserves any parameters which haven't already been escaped or preserved, joins the resulting elements with a space, and wraps the resulting string in an object which is passed through verbatim when passed as a direct or nested parameter to shell, shell.escape, or shell.preserve.

DEVELOPMENT

NPM Scripts

The following NPM scripts are available:

  • test - lint the codebase, compile the library, and run the test suite

Gulp Tasks

The following Gulp tasks are available:

  • build - compile the library and save it to the target directory
  • clean - remove the target directory and its contents
  • default - run the lint and build tasks
  • dump:config - print the build config settings to the console
  • lint - check and report style and usage errors in the gulpfile, source file(s) and test file(s)

SEE ALSO

  • any-shell-escape - Escape and stringify an array of arguments to be executed on the shell
  • execa - A better child_process
  • shell-tag - Run shell commands inline in JavaScript with ES6 template strings

COPYRIGHT AND LICENSE

Copyright © 2015-2018 by chocolateboy.

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.