mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
Instead of calling into C++ each time we need to check the value of a command line option, cache the option map in a new `internal/options` module for faster access to the values in JS land. PR-URL: https://github.com/nodejs/node/pull/24091 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Refael Ackermann <refack@gmail.com>
24 lines
533 B
JavaScript
24 lines
533 B
JavaScript
'use strict';
|
|
const { options, aliases } = require('internal/options');
|
|
|
|
function print(stream) {
|
|
const all_opts = [...options.keys(), ...aliases.keys()];
|
|
|
|
stream.write(`_node_complete() {
|
|
local cur_word options
|
|
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
|
if [[ "\${cur_word}" == -* ]] ; then
|
|
COMPREPLY=( $(compgen -W '${all_opts.join(' ')}' -- "\${cur_word}") )
|
|
return 0
|
|
else
|
|
COMPREPLY=( $(compgen -f "\${cur_word}") )
|
|
return 0
|
|
fi
|
|
}
|
|
complete -F _node_complete node node_g`);
|
|
}
|
|
|
|
module.exports = {
|
|
print
|
|
};
|