@ff0000-ad-tech/unix-path-literal
v1.0.2
Published
OS file-systems can use control characters in file/directory names. You may need to escape them in some circumstances.
Downloads
7
Readme
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