forked from jamesshore/lets_code_javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirs.js
More file actions
37 lines (27 loc) · 814 Bytes
/
dirs.js
File metadata and controls
37 lines (27 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var shell = require('..');
var assert = require('assert'),
path = require('path'),
fs = require('fs');
// Node shims for < v0.7
fs.existsSync = fs.existsSync || path.existsSync;
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);