1 | var test = require('tape');
|
2 | var quote = require('../').quote;
|
3 |
|
4 | test('quote', function (t) {
|
5 | t.equal(quote([ 'a', 'b', 'c d' ]), 'a b \'c d\'');
|
6 | t.equal(
|
7 | quote([ 'a', 'b', "it's a \"neat thing\"" ]),
|
8 | 'a b "it\'s a \\"neat thing\\""'
|
9 | );
|
10 | t.equal(
|
11 | quote([ '$', '`', '\'' ]),
|
12 | '\\$ \\` "\'"'
|
13 | );
|
14 | t.equal(quote([]), '');
|
15 | t.equal(quote(["a\nb"]), "'a\nb'");
|
16 | t.equal(quote([' #(){}*|][!']), "' #(){}*|][!'");
|
17 | t.equal(quote(["'#(){}*|][!"]), '"\'#(){}*|][\\!"');
|
18 | t.equal(quote(["X#(){}*|][!"]), "X\\#\\(\\)\\{\\}\\*\\|\\]\\[\\!");
|
19 | t.equal(quote(["a\n#\nb"]), "'a\n#\nb'");
|
20 | t.equal(quote(['><;{}']), '\\>\\<\\;\\{\\}');
|
21 | t.equal(quote([ 'a', 1, true, false ]), 'a 1 true false');
|
22 | t.equal(quote([ 'a', 1, null, undefined ]), 'a 1 null undefined');
|
23 | t.equal(quote([ 'a\\x' ]), 'a\\\\x');
|
24 | t.end();
|
25 | });
|
26 |
|
27 | test('quote ops', function (t) {
|
28 | t.equal(quote([ 'a', { op: '|' }, 'b' ]), 'a \\| b');
|
29 | t.equal(
|
30 | quote([ 'a', { op: '&&' }, 'b', { op: ';' }, 'c' ]),
|
31 | 'a \\&\\& b \\; c'
|
32 | );
|
33 | t.end();
|
34 | });
|
35 |
|
36 | test('quote windows paths', { skip: 'breaking change, disabled until 2.x' }, function (t) {
|
37 | var path = 'C:\\projects\\node-shell-quote\\index.js'
|
38 |
|
39 | t.equal(quote([path, 'b', 'c d']), 'C:\\projects\\node-shell-quote\\index.js b \'c d\'')
|
40 |
|
41 | t.end()
|
42 | })
|
43 |
|
44 | test("chars for windows paths don't break out", function (t) {
|
45 | var x = '`:\\a\\b'
|
46 | t.equal(quote([x]), '\\`\\:\\\\a\\\\b')
|
47 | t.end()
|
48 | })
|