(options, index)
| 125 | //@ |
| 126 | //@ When no arguments are given, `popd` removes the top directory from the stack and performs a `cd` to the new top directory. The elements are numbered from 0, starting at the first directory listed with dirs (i.e., `popd` is equivalent to `popd +0`). Returns an array of paths in the stack. |
| 127 | function _popd(options, index) { |
| 128 | if (_isStackIndex(options)) { |
| 129 | index = options; |
| 130 | options = ''; |
| 131 | } |
| 132 | |
| 133 | options = common.parseOptions(options, { |
| 134 | 'n': 'no-cd', |
| 135 | 'q': 'quiet', |
| 136 | }); |
| 137 | |
| 138 | if (!_dirStack.length) { |
| 139 | return common.error('directory stack empty'); |
| 140 | } |
| 141 | |
| 142 | index = _parseStackIndex(index || '+0'); |
| 143 | |
| 144 | if (options['no-cd'] || index > 0 || _dirStack.length + index === 0) { |
| 145 | index = index > 0 ? index - 1 : index; |
| 146 | _dirStack.splice(index, 1); |
| 147 | } else { |
| 148 | var dir = path.resolve(_dirStack.shift()); |
| 149 | _cd('', dir); |
| 150 | } |
| 151 | |
| 152 | return _dirs(options.quiet ? '-q' : ''); |
| 153 | } |
| 154 | exports.popd = _popd; |
| 155 | |
| 156 | //@ |
nothing calls this directly
no test coverage detected
searching dependent graphs…