-
Notifications
You must be signed in to change notification settings - Fork 723
/
config.js
69 lines (56 loc) · 2.04 KB
/
config.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var shell = require('..');
var assert = require('assert');
var child = require('child_process');
var common = require('../src/common');
//
// config.silent
//
assert.equal(shell.config.silent, false); // default
shell.config.silent = true;
assert.equal(shell.config.silent, true);
shell.config.silent = false;
assert.equal(shell.config.silent, false);
//
// config.fatal
//
assert.equal(shell.config.fatal, false); // default
//
// config.fatal = false
//
shell.mkdir('-p', 'tmp');
var file = 'tmp/tempscript' + Math.random() + '.js';
var script = 'require(\'../../global.js\'); config.silent=true; config.fatal=false; cp("this_file_doesnt_exist", "."); echo("got here");';
shell.ShellString(script).to(file);
child.exec(JSON.stringify(common.nodeBinPath) + ' ' + file, function (err, stdout) {
assert.ok(stdout.match('got here'));
//
// config.fatal = true
//
shell.mkdir('-p', 'tmp');
file = 'tmp/tempscript' + Math.random() + '.js';
script = 'require(\'../../global.js\'); config.silent=true; config.fatal=true; cp("this_file_doesnt_exist", "."); echo("got here");';
shell.ShellString(script).to(file);
child.exec(JSON.stringify(common.nodeBinPath) + ' ' + file, function (err2, stdout2) {
assert.ok(!stdout2.match('got here'));
shell.exit(123);
});
});
//
// config.globOptions
//
// Expands to directories by default
var result = common.expand(['resources/*a*']);
assert.equal(result.length, 5);
assert.ok(result.indexOf('resources/a.txt') > -1);
assert.ok(result.indexOf('resources/badlink') > -1);
assert.ok(result.indexOf('resources/cat') > -1);
assert.ok(result.indexOf('resources/head') > -1);
assert.ok(result.indexOf('resources/external') > -1);
// Check to make sure options get passed through (nodir is an example)
shell.config.globOptions = { nodir: true };
result = common.expand(['resources/*a*']);
assert.equal(result.length, 2);
assert.ok(result.indexOf('resources/a.txt') > -1);
assert.ok(result.indexOf('resources/badlink') > -1);
assert.ok(result.indexOf('resources/cat') < 0);
assert.ok(result.indexOf('resources/external') < 0);