1.0.2 • Published 6 years ago

@ff0000-ad-tech/unix-path-literal v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Unix Path Literal

Different systems can use unix control characters in file/directory names. If trying to render the literal escapes, you may need extra escaping.

Disclaimer: If you're using your spawning module correctly, you do not need this. But if you need to return a Terminal-safe executable string to a view, then this might be handy.

The replacements:

The list is not exhaustive -- just the characters that our users constantly use:

  • -> \
  • ' -> \'
  • ( -> \(
  • ) -> \)
  • - -> \-
  • & -> \&

Install

npm install git://github.com:gmcdev/unix-path-literal.git --save

Usage

const unixPathLiteral = require('unix-path-literal');

const command = `Project/ESPN Wimbledon 2017 -- CLONE/creative (version 1 & '2')/my-bash-script.sh`;
console.log(unixPathLiteral(command));
// => Project/ESPN\ Wimbledon\ 2017\ \-\-\ CLONE/creative\ \(version\ 1\ \&\ \'2\'\)/my\-bash\-script.sh