forked from pattern-lab/patternlab-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
85 lines (84 loc) · 2.23 KB
/
cli.js
File metadata and controls
85 lines (84 loc) · 2.23 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var assert = require('assert');
var path = require('path');
var exec = require('child_process').execFile;
var cmd = path.join(__dirname, '..', 'live-server.js');
var opts = {
timeout: 2000,
maxBuffer: 1024,
};
function exec_test(args, callback) {
if (process.platform === 'win32')
exec(process.execPath, [cmd].concat(args), opts, callback);
else exec(cmd, args, opts, callback);
}
describe('command line usage', function() {
it('--version', function(done) {
exec_test(['--version'], function(error, stdout, stdin) {
assert(!error, error);
assert(stdout.indexOf('live-server') == 0, 'version not found');
done();
});
});
it('--help', function(done) {
exec_test(['--help'], function(error, stdout, stdin) {
assert(!error, error);
assert(stdout.indexOf('Usage: live-server') == 0, 'usage not found');
done();
});
});
it('--quiet', function(done) {
exec_test(['--quiet', '--no-browser', '--test'], function(
error,
stdout,
stdin
) {
assert(!error, error);
assert(stdout === '', 'stdout not empty');
done();
});
});
it('--port', function(done) {
exec_test(['--port=16123', '--no-browser', '--test'], function(
error,
stdout,
stdin
) {
assert(!error, error);
assert(stdout.indexOf('Serving') == 0, 'serving string not found');
assert(
stdout.indexOf('at http://127.0.0.1:16123') != -1,
'port string not found'
);
done();
});
});
it('--host', function(done) {
exec_test(['--host=localhost', '--no-browser', '--test'], function(
error,
stdout,
stdin
) {
assert(!error, error);
assert(stdout.indexOf('Serving') == 0, 'serving string not found');
assert(
stdout.indexOf('at http://localhost:') != -1,
'host string not found'
);
done();
});
});
it('--htpasswd', function(done) {
exec_test(
[
'--htpasswd=' + path.join(__dirname, 'data/htpasswd-test'),
'--no-browser',
'--test',
],
function(error, stdout, stdin) {
assert(!error, error);
assert(stdout.indexOf('Serving') == 0, 'serving string not found');
done();
}
);
});
});