11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst child_process = require('child_process'); 51cb0ef41Sopenharmony_ciconst { debuglog, inspect } = require('util'); 61cb0ef41Sopenharmony_ciconst debug = debuglog('test'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst p = child_process.spawnSync( 91cb0ef41Sopenharmony_ci process.execPath, [ '--completion-bash' ]); 101cb0ef41Sopenharmony_ciassert.ifError(p.error); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst output = p.stdout.toString().trim().replace(/\r/g, ''); 131cb0ef41Sopenharmony_cidebug(output); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst prefix = `_node_complete() { 161cb0ef41Sopenharmony_ci local cur_word options 171cb0ef41Sopenharmony_ci cur_word="\${COMP_WORDS[COMP_CWORD]}" 181cb0ef41Sopenharmony_ci if [[ "\${cur_word}" == -* ]] ; then 191cb0ef41Sopenharmony_ci COMPREPLY=( $(compgen -W '`.replace(/\r/g, ''); 201cb0ef41Sopenharmony_ciconst suffix = `' -- "\${cur_word}") ) 211cb0ef41Sopenharmony_ci return 0 221cb0ef41Sopenharmony_ci else 231cb0ef41Sopenharmony_ci COMPREPLY=( $(compgen -f "\${cur_word}") ) 241cb0ef41Sopenharmony_ci return 0 251cb0ef41Sopenharmony_ci fi 261cb0ef41Sopenharmony_ci} 271cb0ef41Sopenharmony_cicomplete -o filenames -o nospace -o bashdefault -F _node_complete node node_g` 281cb0ef41Sopenharmony_ci .replace(/\r/g, ''); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciassert.ok( 311cb0ef41Sopenharmony_ci output.includes(prefix), 321cb0ef41Sopenharmony_ci `Expect\n\n ${inspect(output)}\n\nto include\n\n${inspect(prefix)}`); 331cb0ef41Sopenharmony_ciassert.ok( 341cb0ef41Sopenharmony_ci output.includes(suffix), 351cb0ef41Sopenharmony_ci `Expect\n\n ${inspect(output)}\n\nto include\n\n${inspect(suffix)}`); 36