MCPcopy
hub / github.com/shelljs/shelljs / _popd

Function _popd

src/dirs.js:127–153  ·  view source on GitHub ↗
(options, index)

Source from the content-addressed store, hash-verified

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.
127function _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}
154exports.popd = _popd;
155
156//@

Callers

nothing calls this directly

Calls 4

_isStackIndexFunction · 0.85
_parseStackIndexFunction · 0.85
_cdFunction · 0.85
_dirsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…