summaryrefslogtreecommitdiff
path: root/lib/internal/main/print_bash_completion.js
blob: 41ebf0c6063e5f7cb4e2b5026f9987695955570f (plain)
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
'use strict';
const { options, aliases } = require('internal/options');

const {
  prepareMainThreadExecution
} = require('internal/bootstrap/pre_execution');

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`);
}

prepareMainThreadExecution();

markBootstrapComplete();

print(process.stdout);