(options, dir)
| 58 | //@ |
| 59 | //@ Save the current directory on the top of the directory stack and then `cd` to `dir`. With no arguments, `pushd` exchanges the top two directories. Returns an array of paths in the stack. |
| 60 | function _pushd(options, dir) { |
| 61 | if (_isStackIndex(options)) { |
| 62 | dir = options; |
| 63 | options = ''; |
| 64 | } |
| 65 | |
| 66 | options = common.parseOptions(options, { |
| 67 | 'n': 'no-cd', |
| 68 | 'q': 'quiet', |
| 69 | }); |
| 70 | |
| 71 | var dirs = _actualDirStack(); |
| 72 | |
| 73 | if (dir === '+0') { |
| 74 | return dirs; // +0 is a noop |
| 75 | } else if (!dir) { |
| 76 | if (dirs.length > 1) { |
| 77 | dirs = dirs.splice(1, 1).concat(dirs); |
| 78 | } else { |
| 79 | return common.error('no other directory'); |
| 80 | } |
| 81 | } else if (_isStackIndex(dir)) { |
| 82 | var n = _parseStackIndex(dir); |
| 83 | dirs = dirs.slice(n).concat(dirs.slice(0, n)); |
| 84 | } else if (options['no-cd']) { |
| 85 | dirs.splice(1, 0, dir); |
| 86 | } else { |
| 87 | dirs.unshift(dir); |
| 88 | } |
| 89 | |
| 90 | if (options['no-cd']) { |
| 91 | dirs = dirs.slice(1); |
| 92 | } else { |
| 93 | dir = path.resolve(dirs.shift()); |
| 94 | _cd('', dir); |
| 95 | } |
| 96 | |
| 97 | _dirStack = dirs; |
| 98 | return _dirs(options.quiet ? '-q' : ''); |
| 99 | } |
| 100 | exports.pushd = _pushd; |
| 101 | |
| 102 | //@ |
nothing calls this directly
no test coverage detected
searching dependent graphs…