2018-11-06 15:52:09 +00:00
|
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const child_process = require('child_process');
|
2020-03-23 13:06:24 -07:00
|
|
|
const { debuglog, inspect } = require('util');
|
|
|
|
const debug = debuglog('test');
|
2018-11-06 15:52:09 +00:00
|
|
|
|
|
|
|
const p = child_process.spawnSync(
|
|
|
|
process.execPath, [ '--completion-bash' ]);
|
|
|
|
assert.ifError(p.error);
|
2019-02-03 11:47:26 +08:00
|
|
|
|
|
|
|
const output = p.stdout.toString().trim().replace(/\r/g, '');
|
2020-03-23 13:06:24 -07:00
|
|
|
debug(output);
|
2019-02-03 11:47:26 +08:00
|
|
|
|
|
|
|
const prefix = `_node_complete() {
|
2018-11-06 15:52:09 +00:00
|
|
|
local cur_word options
|
|
|
|
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
if [[ "\${cur_word}" == -* ]] ; then
|
2019-02-03 11:47:26 +08:00
|
|
|
COMPREPLY=( $(compgen -W '`.replace(/\r/g, '');
|
|
|
|
const suffix = `' -- "\${cur_word}") )
|
2018-11-06 15:52:09 +00:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
COMPREPLY=( $(compgen -f "\${cur_word}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
2020-06-05 14:17:13 +02:00
|
|
|
complete -o filenames -o nospace -o bashdefault -F _node_complete node node_g`
|
|
|
|
.replace(/\r/g, '');
|
2019-02-03 11:47:26 +08:00
|
|
|
|
|
|
|
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)}`);
|