forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-bash-completion.js
33 lines (29 loc) · 945 Bytes
/
test-bash-completion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
require('../common');
const assert = require('assert');
const child_process = require('child_process');
const { inspect } = require('util');
const p = child_process.spawnSync(
process.execPath, [ '--completion-bash' ]);
assert.ifError(p.error);
const output = p.stdout.toString().trim().replace(/\r/g, '');
console.log(output);
const prefix = `_node_complete() {
local cur_word options
cur_word="\${COMP_WORDS[COMP_CWORD]}"
if [[ "\${cur_word}" == -* ]] ; then
COMPREPLY=( $(compgen -W '`.replace(/\r/g, '');
const suffix = `' -- "\${cur_word}") )
return 0
else
COMPREPLY=( $(compgen -f "\${cur_word}") )
return 0
fi
}
complete -F _node_complete node node_g`.replace(/\r/g, '');
assert.ok(
output.includes(prefix),
`Expect\n\n ${inspect(output)}\n\nto include\n\n${inspect(prefix)}`);
assert.ok(
output.includes(suffix),
`Expect\n\n ${inspect(output)}\n\nto include\n\n${inspect(suffix)}`);