shelljs/test/dirs.js
Nate Fischer 2395214fee chore: switch to eslint (#504)
* chore: switch to eslint

* fix: works on older versions of NodeJS now

* chore: fix curly braces

* chore: fix indents and remove jshint references
2016-08-07 12:16:29 -07:00

34 lines
715 B
JavaScript

var shell = require('..');
var assert = require('assert');
var path = require('path');
shell.config.silent = true;
var root = path.resolve();
shell.pushd('resources/pushd');
shell.pushd('a');
var trail = [
path.resolve(root, 'resources/pushd/a'),
path.resolve(root, 'resources/pushd'),
root
];
assert.deepEqual(shell.dirs(), trail);
// Single items
assert.equal(shell.dirs('+0'), trail[0]);
assert.equal(shell.dirs('+1'), trail[1]);
assert.equal(shell.dirs('+2'), trail[2]);
assert.equal(shell.dirs('-0'), trail[2]);
assert.equal(shell.dirs('-1'), trail[1]);
assert.equal(shell.dirs('-2'), trail[0]);
// Clearing items
assert.deepEqual(shell.dirs('-c'), []);
assert(!shell.error());
shell.exit(123);