(options, index)
| 171 | //@ |
| 172 | //@ See also: `pushd`, `popd` |
| 173 | function _dirs(options, index) { |
| 174 | if (_isStackIndex(options)) { |
| 175 | index = options; |
| 176 | options = ''; |
| 177 | } |
| 178 | |
| 179 | options = common.parseOptions(options, { |
| 180 | 'c': 'clear', |
| 181 | 'q': 'quiet', |
| 182 | }); |
| 183 | |
| 184 | if (options.clear) { |
| 185 | _dirStack = []; |
| 186 | return _dirStack; |
| 187 | } |
| 188 | |
| 189 | var stack = _actualDirStack(); |
| 190 | |
| 191 | if (index) { |
| 192 | index = _parseStackIndex(index); |
| 193 | |
| 194 | if (index < 0) { |
| 195 | index = stack.length + index; |
| 196 | } |
| 197 | |
| 198 | if (!options.quiet) { |
| 199 | common.log(stack[index]); |
| 200 | } |
| 201 | return stack[index]; |
| 202 | } |
| 203 | |
| 204 | if (!options.quiet) { |
| 205 | common.log(stack.join(' ')); |
| 206 | } |
| 207 | |
| 208 | return stack; |
| 209 | } |
| 210 | exports.dirs = _dirs; |
no test coverage detected
searching dependent graphs…