mirror of https://github.com/mthenw/frontail.git
chore: prettier standard
parent
0ceb864693
commit
94e2c46ee6
21
index.js
21
index.js
|
@ -37,16 +37,13 @@ const doAuthorization = !!(program.user && program.password);
|
|||
const doSecure = !!(program.key && program.certificate);
|
||||
const sessionSecret = String(+new Date()) + Math.random();
|
||||
const files = program.args.join(' ');
|
||||
const filesNamespace = crypto
|
||||
.createHash('md5')
|
||||
.update(files)
|
||||
.digest('hex');
|
||||
const filesNamespace = crypto.createHash('md5').update(files).digest('hex');
|
||||
const urlPath = program.urlPath.replace(/\/$/, ''); // remove trailing slash
|
||||
|
||||
if (program.daemonize) {
|
||||
daemonize(__filename, program, {
|
||||
doAuthorization,
|
||||
doSecure
|
||||
doSecure,
|
||||
});
|
||||
} else {
|
||||
/**
|
||||
|
@ -59,7 +56,12 @@ if (program.daemonize) {
|
|||
}
|
||||
appBuilder
|
||||
.static(path.join(__dirname, 'web', 'assets'))
|
||||
.index(path.join(__dirname, 'web', 'index.html'), files, filesNamespace, program.theme);
|
||||
.index(
|
||||
path.join(__dirname, 'web', 'index.html'),
|
||||
files,
|
||||
filesNamespace,
|
||||
program.theme
|
||||
);
|
||||
|
||||
const builder = serverBuilder();
|
||||
if (doSecure) {
|
||||
|
@ -86,7 +88,10 @@ if (program.daemonize) {
|
|||
if (!sessionIdEncoded) {
|
||||
return next(new Error('Session cookie not provided'), false);
|
||||
}
|
||||
const sessionId = cookieParser.signedCookie(sessionIdEncoded, sessionSecret);
|
||||
const sessionId = cookieParser.signedCookie(
|
||||
sessionIdEncoded,
|
||||
sessionSecret
|
||||
);
|
||||
if (sessionId) {
|
||||
return next(null);
|
||||
}
|
||||
|
@ -121,7 +126,7 @@ if (program.daemonize) {
|
|||
* When connected send starting data
|
||||
*/
|
||||
const tailer = tail(program.args, {
|
||||
buffer: program.number
|
||||
buffer: program.number,
|
||||
});
|
||||
|
||||
const filesSocket = io.of(`/${filesNamespace}`).on('connection', (socket) => {
|
||||
|
|
|
@ -38,7 +38,7 @@ ConnectBuilder.prototype.index = function index(
|
|||
this.app.use(this.urlPath, (req, res) => {
|
||||
fs.readFile(path, (err, data) => {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/html'
|
||||
'Content-Type': 'text/html',
|
||||
});
|
||||
res.end(
|
||||
data
|
||||
|
@ -61,7 +61,7 @@ ConnectBuilder.prototype.session = function sessionf(secret) {
|
|||
expressSession({
|
||||
secret,
|
||||
resave: false,
|
||||
saveUninitialized: true
|
||||
saveUninitialized: true,
|
||||
})
|
||||
);
|
||||
return this;
|
||||
|
|
|
@ -5,7 +5,7 @@ const fs = require('fs');
|
|||
|
||||
const defaultOptions = {
|
||||
doAuthorization: false,
|
||||
doSecure: false
|
||||
doSecure: false,
|
||||
};
|
||||
|
||||
module.exports = (script, params, opts) => {
|
||||
|
@ -23,7 +23,7 @@ module.exports = (script, params, opts) => {
|
|||
'-l',
|
||||
params.lines,
|
||||
'-t',
|
||||
params.theme
|
||||
params.theme,
|
||||
];
|
||||
|
||||
if (options.doAuthorization) {
|
||||
|
@ -58,7 +58,7 @@ module.exports = (script, params, opts) => {
|
|||
|
||||
const proc = daemon.daemon(script, args, {
|
||||
stdout: logFile,
|
||||
stderr: logFile
|
||||
stderr: logFile,
|
||||
});
|
||||
|
||||
fs.writeFileSync(params.pidPath, proc.pid);
|
||||
|
|
|
@ -4,11 +4,31 @@ program
|
|||
.version(require('../package.json').version)
|
||||
.usage('[options] [file ...]')
|
||||
.helpOption('--help')
|
||||
.option('-h, --host <host>', 'listening host, default 0.0.0.0', String, '0.0.0.0')
|
||||
.option(
|
||||
'-h, --host <host>',
|
||||
'listening host, default 0.0.0.0',
|
||||
String,
|
||||
'0.0.0.0'
|
||||
)
|
||||
.option('-p, --port <port>', 'listening port, default 9001', Number, 9001)
|
||||
.option('-n, --number <number>', 'starting lines number, default 10', Number, 10)
|
||||
.option('-l, --lines <lines>', 'number on lines stored in browser, default 2000', Number, 2000)
|
||||
.option('-t, --theme <theme>', 'name of the theme (default, dark)', String, 'default')
|
||||
.option(
|
||||
'-n, --number <number>',
|
||||
'starting lines number, default 10',
|
||||
Number,
|
||||
10
|
||||
)
|
||||
.option(
|
||||
'-l, --lines <lines>',
|
||||
'number on lines stored in browser, default 2000',
|
||||
Number,
|
||||
2000
|
||||
)
|
||||
.option(
|
||||
'-t, --theme <theme>',
|
||||
'name of the theme (default, dark)',
|
||||
String,
|
||||
'default'
|
||||
)
|
||||
.option('-d, --daemonize', 'run as daemon')
|
||||
.option(
|
||||
'-U, --user <username>',
|
||||
|
@ -46,7 +66,12 @@ program
|
|||
String,
|
||||
'/dev/null'
|
||||
)
|
||||
.option('--url-path <path>', 'URL path for the browser application, default /', String, '/')
|
||||
.option(
|
||||
'--url-path <path>',
|
||||
'URL path for the browser application, default /',
|
||||
String,
|
||||
'/'
|
||||
)
|
||||
.option('--ui-hide-topbar', 'hide topbar (log file name and search box)')
|
||||
.option('--ui-no-indent', "don't indent log lines")
|
||||
.option(
|
||||
|
|
|
@ -15,9 +15,11 @@ ServerBuilder.prototype.build = function build() {
|
|||
if (this._key && this._cert) {
|
||||
const options = {
|
||||
key: this._key,
|
||||
cert: this._cert
|
||||
cert: this._cert,
|
||||
};
|
||||
return https.createServer(options, this._callback).listen(this._port, this._host);
|
||||
return https
|
||||
.createServer(options, this._callback)
|
||||
.listen(this._port, this._host);
|
||||
}
|
||||
|
||||
return http.createServer(this._callback).listen(this._port, this._host);
|
||||
|
|
|
@ -61,7 +61,9 @@ Stats.prototype.timeEnd = function timeEnd(category, action, cb) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.tracker.timing(category, action, Date.now() - this.timer[category][action]).send(cb);
|
||||
this.tracker
|
||||
.timing(category, action, Date.now() - this.timer[category][action])
|
||||
.send(cb);
|
||||
};
|
||||
|
||||
module.exports = (enabled, opts) => new Stats(enabled, opts);
|
||||
|
|
|
@ -14,7 +14,7 @@ function Tail(path, opts) {
|
|||
events.EventEmitter.call(this);
|
||||
|
||||
const options = opts || {
|
||||
buffer: 0
|
||||
buffer: 0,
|
||||
};
|
||||
this._buffer = new CBuffer(options.buffer);
|
||||
|
||||
|
@ -52,7 +52,7 @@ function Tail(path, opts) {
|
|||
stream = tailStream.createReadStream(path.join(), {
|
||||
encoding: 'utf8',
|
||||
start: options.buffer,
|
||||
tail: true
|
||||
tail: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1231,6 +1231,15 @@
|
|||
"object.entries": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"eslint-config-prettier": {
|
||||
"version": "6.10.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.10.1.tgz",
|
||||
"integrity": "sha512-svTy6zh1ecQojvpbJSgH3aei/Rt7C6i090l5f2WQ4aB05lYHeZIR1qL4wZyyILTbtmnbHP5Yn8MrsOJMGa8RkQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"get-stdin": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"eslint-import-resolver-node": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz",
|
||||
|
@ -1731,6 +1740,12 @@
|
|||
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
|
||||
"dev": true
|
||||
},
|
||||
"get-stdin": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
|
||||
"integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==",
|
||||
"dev": true
|
||||
},
|
||||
"get-value": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",
|
||||
|
|
14
package.json
14
package.json
|
@ -29,6 +29,7 @@
|
|||
"devDependencies": {
|
||||
"eslint": "~6.8.0",
|
||||
"eslint-config-airbnb-base": "~14.0.0",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint-plugin-import": "~2.20.0",
|
||||
"jsdom": "~11.12.0",
|
||||
"mocha": "~5.2.0",
|
||||
|
@ -55,17 +56,14 @@
|
|||
]
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "airbnb-base",
|
||||
"extends": [
|
||||
"airbnb-base",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"strict": "off",
|
||||
"implicit-arrow-linebreak": "off",
|
||||
"comma-dangle": [
|
||||
"error",
|
||||
{
|
||||
"functions": "never"
|
||||
}
|
||||
]
|
||||
"implicit-arrow-linebreak": "off"
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
|
|
23
test/app.js
23
test/app.js
|
@ -15,7 +15,7 @@ describe('browser application', () => {
|
|||
filterInput: window.document.querySelector('#filter'),
|
||||
pauseBtn: window.document.querySelector('#pauseBtn'),
|
||||
topbar: window.document.querySelector('.topbar'),
|
||||
body: window.document.querySelector('body')
|
||||
body: window.document.querySelector('body'),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,10 @@ describe('browser application', () => {
|
|||
|
||||
beforeEach((done) => {
|
||||
io = new events.EventEmitter();
|
||||
const html = '<title></title><body><div class="topbar"></div>'
|
||||
+ '<div class="log"></div><button type="button" id="pauseBtn"></button>'
|
||||
+ '<input type="test" id="filter"/></body>';
|
||||
const html =
|
||||
'<title></title><body><div class="topbar"></div>' +
|
||||
'<div class="log"></div><button type="button" id="pauseBtn"></button>' +
|
||||
'<input type="test" id="filter"/></body>';
|
||||
const ansiup = fs.readFileSync('./web/assets/ansi_up.js', 'utf-8');
|
||||
const src = fs.readFileSync('./web/assets/app.js', 'utf-8');
|
||||
|
||||
|
@ -58,7 +59,7 @@ describe('browser application', () => {
|
|||
|
||||
initApp();
|
||||
done();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -70,7 +71,9 @@ describe('browser application', () => {
|
|||
log.childNodes[0].textContent.should.be.equal('test');
|
||||
log.childNodes[0].className.should.be.equal('line');
|
||||
log.childNodes[0].tagName.should.be.equal('DIV');
|
||||
log.childNodes[0].innerHTML.should.be.equal('<p class="inner-line">test</p>');
|
||||
log.childNodes[0].innerHTML.should.be.equal(
|
||||
'<p class="inner-line">test</p>'
|
||||
);
|
||||
});
|
||||
|
||||
it('should select line when clicked', () => {
|
||||
|
@ -124,8 +127,8 @@ describe('browser application', () => {
|
|||
io.emit('options:highlightConfig', {
|
||||
words: {
|
||||
foo: 'background: black',
|
||||
bar: 'background: black'
|
||||
}
|
||||
bar: 'background: black',
|
||||
},
|
||||
});
|
||||
io.emit('line', 'foo bar');
|
||||
|
||||
|
@ -138,8 +141,8 @@ describe('browser application', () => {
|
|||
it('should highlight line', () => {
|
||||
io.emit('options:highlightConfig', {
|
||||
lines: {
|
||||
line: 'background: black'
|
||||
}
|
||||
line: 'background: black',
|
||||
},
|
||||
});
|
||||
io.emit('line', 'line1');
|
||||
|
||||
|
|
|
@ -6,18 +6,12 @@ const connectBuilder = require('../lib/connect_builder');
|
|||
|
||||
describe('connectBuilder', () => {
|
||||
it('should build connect app', () => {
|
||||
connectBuilder('/')
|
||||
.build()
|
||||
.should.have.property('use');
|
||||
connectBuilder()
|
||||
.build()
|
||||
.should.have.property('listen');
|
||||
connectBuilder('/').build().should.have.property('use');
|
||||
connectBuilder().build().should.have.property('listen');
|
||||
});
|
||||
|
||||
it('should build app requiring authorized user', (done) => {
|
||||
const app = connectBuilder('/')
|
||||
.authorize('user', 'pass')
|
||||
.build();
|
||||
const app = connectBuilder('/').authorize('user', 'pass').build();
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
|
@ -26,9 +20,7 @@ describe('connectBuilder', () => {
|
|||
});
|
||||
|
||||
it('should build app allowing user to login', (done) => {
|
||||
const app = connectBuilder('/')
|
||||
.authorize('user', 'pass')
|
||||
.build();
|
||||
const app = connectBuilder('/').authorize('user', 'pass').build();
|
||||
app.use((req, res) => {
|
||||
res.end('secret!');
|
||||
});
|
||||
|
@ -40,9 +32,7 @@ describe('connectBuilder', () => {
|
|||
});
|
||||
|
||||
it('should build app that setup session', (done) => {
|
||||
const app = connectBuilder('/')
|
||||
.session('secret')
|
||||
.build();
|
||||
const app = connectBuilder('/').session('secret').build();
|
||||
app.use((req, res) => {
|
||||
res.end();
|
||||
});
|
||||
|
@ -57,9 +47,7 @@ describe('connectBuilder', () => {
|
|||
.static(path.join(__dirname, 'fixtures'))
|
||||
.build();
|
||||
|
||||
request(app)
|
||||
.get('/foo.txt')
|
||||
.expect('bar', done);
|
||||
request(app).get('/foo.txt').expect('bar', done);
|
||||
});
|
||||
|
||||
it('should build app that serve index file', (done) => {
|
||||
|
@ -67,10 +55,7 @@ describe('connectBuilder', () => {
|
|||
.index(path.join(__dirname, 'fixtures/index'), '/testfile')
|
||||
.build();
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Content-Type', 'text/html', done);
|
||||
request(app).get('/').expect(200).expect('Content-Type', 'text/html', done);
|
||||
});
|
||||
|
||||
it('should build app that serve index file on specified path', (done) => {
|
||||
|
@ -89,24 +74,30 @@ describe('connectBuilder', () => {
|
|||
.index(path.join(__dirname, 'fixtures/index_with_title'), '/testfile')
|
||||
.build();
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('<head><title>/testfile</title></head>', done);
|
||||
request(app).get('/').expect('<head><title>/testfile</title></head>', done);
|
||||
});
|
||||
|
||||
it('should build app that sets socket.io namespace based on files', (done) => {
|
||||
const app = connectBuilder('/')
|
||||
.index(path.join(__dirname, 'fixtures/index_with_ns'), '/testfile', 'ns', 'dark')
|
||||
.index(
|
||||
path.join(__dirname, 'fixtures/index_with_ns'),
|
||||
'/testfile',
|
||||
'ns',
|
||||
'dark'
|
||||
)
|
||||
.build();
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('ns', done);
|
||||
request(app).get('/').expect('ns', done);
|
||||
});
|
||||
|
||||
it('should build app that sets theme', (done) => {
|
||||
const app = connectBuilder('/')
|
||||
.index(path.join(__dirname, '/fixtures/index_with_theme'), '/testfile', 'ns', 'dark')
|
||||
.index(
|
||||
path.join(__dirname, '/fixtures/index_with_theme'),
|
||||
'/testfile',
|
||||
'ns',
|
||||
'dark'
|
||||
)
|
||||
.build();
|
||||
|
||||
request(app)
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('daemonize', () => {
|
|||
beforeEach(() => {
|
||||
sinon.stub(daemon, 'daemon');
|
||||
daemon.daemon.returns({
|
||||
pid: 1000
|
||||
pid: 1000,
|
||||
});
|
||||
sinon.stub(fs, 'writeFileSync');
|
||||
sinon.stub(fs, 'openSync');
|
||||
|
@ -70,41 +70,89 @@ describe('daemonize', () => {
|
|||
});
|
||||
|
||||
it('with authorization', () => {
|
||||
optionsParser.parse(['node', '/path/to/frontail', '-U', 'user', '-P', 'passw0rd']);
|
||||
optionsParser.parse([
|
||||
'node',
|
||||
'/path/to/frontail',
|
||||
'-U',
|
||||
'user',
|
||||
'-P',
|
||||
'passw0rd',
|
||||
]);
|
||||
|
||||
daemonize('script', optionsParser, {
|
||||
doAuthorization: true
|
||||
doAuthorization: true,
|
||||
});
|
||||
|
||||
daemon.daemon.lastCall.args[1].should.containDeep(['-U', 'user', '-P', 'passw0rd']);
|
||||
daemon.daemon.lastCall.args[1].should.containDeep([
|
||||
'-U',
|
||||
'user',
|
||||
'-P',
|
||||
'passw0rd',
|
||||
]);
|
||||
});
|
||||
|
||||
it('without authorization if option doAuthorization not passed', () => {
|
||||
optionsParser.parse(['node', '/path/to/frontail', '-U', 'user', '-P', 'passw0rd']);
|
||||
optionsParser.parse([
|
||||
'node',
|
||||
'/path/to/frontail',
|
||||
'-U',
|
||||
'user',
|
||||
'-P',
|
||||
'passw0rd',
|
||||
]);
|
||||
|
||||
daemonize('script', optionsParser);
|
||||
|
||||
daemon.daemon.lastCall.args[1].should.not.containDeep(['-U', 'user', '-P', 'passw0rd']);
|
||||
daemon.daemon.lastCall.args[1].should.not.containDeep([
|
||||
'-U',
|
||||
'user',
|
||||
'-P',
|
||||
'passw0rd',
|
||||
]);
|
||||
});
|
||||
|
||||
it('with secure connection', () => {
|
||||
optionsParser.parse(['node', '/path/to/frontail', '-k', 'key.file', '-c', 'cert.file']);
|
||||
optionsParser.parse([
|
||||
'node',
|
||||
'/path/to/frontail',
|
||||
'-k',
|
||||
'key.file',
|
||||
'-c',
|
||||
'cert.file',
|
||||
]);
|
||||
|
||||
daemonize('script', optionsParser, {
|
||||
doSecure: true
|
||||
doSecure: true,
|
||||
});
|
||||
|
||||
daemon.daemon.lastCall.args[1].should.containDeep(['-k', 'key.file', '-c', 'cert.file']);
|
||||
daemon.daemon.lastCall.args[1].should.containDeep([
|
||||
'-k',
|
||||
'key.file',
|
||||
'-c',
|
||||
'cert.file',
|
||||
]);
|
||||
});
|
||||
|
||||
it('without secure connection if option doSecure not passed', () => {
|
||||
optionsParser.parse(['node', '/path/to/frontail', '-k', 'key.file', '-c', 'cert.file']);
|
||||
optionsParser.parse([
|
||||
'node',
|
||||
'/path/to/frontail',
|
||||
'-k',
|
||||
'key.file',
|
||||
'-c',
|
||||
'cert.file',
|
||||
]);
|
||||
|
||||
daemonize('script', optionsParser, {
|
||||
doSecure: true
|
||||
doSecure: true,
|
||||
});
|
||||
|
||||
daemon.daemon.lastCall.args[1].should.containDeep(['-k', 'key.file', '-c', 'cert.file']);
|
||||
daemon.daemon.lastCall.args[1].should.containDeep([
|
||||
'-k',
|
||||
'key.file',
|
||||
'-c',
|
||||
'cert.file',
|
||||
]);
|
||||
});
|
||||
|
||||
it('with url-path option', () => {
|
||||
|
@ -112,7 +160,10 @@ describe('daemonize', () => {
|
|||
|
||||
daemonize('script', optionsParser);
|
||||
|
||||
daemon.daemon.lastCall.args[1].should.containDeep(['--url-path', '/test']);
|
||||
daemon.daemon.lastCall.args[1].should.containDeep([
|
||||
'--url-path',
|
||||
'/test',
|
||||
]);
|
||||
});
|
||||
|
||||
it('with hide-topbar option', () => {
|
||||
|
@ -145,12 +196,15 @@ describe('daemonize', () => {
|
|||
'/path/to/frontail',
|
||||
'--ui-highlight',
|
||||
'--ui-highlight-preset',
|
||||
'test.json'
|
||||
'test.json',
|
||||
]);
|
||||
|
||||
daemonize('script', optionsParser);
|
||||
|
||||
daemon.daemon.lastCall.args[1].should.containDeep(['--ui-highlight-preset', 'test.json']);
|
||||
daemon.daemon.lastCall.args[1].should.containDeep([
|
||||
'--ui-highlight-preset',
|
||||
'test.json',
|
||||
]);
|
||||
});
|
||||
|
||||
it('with file to tail', () => {
|
||||
|
@ -163,7 +217,12 @@ describe('daemonize', () => {
|
|||
});
|
||||
|
||||
it('should write pid to pidfile', () => {
|
||||
optionsParser.parse(['node', '/path/to/frontail', '--pid-path', '/path/to/pid']);
|
||||
optionsParser.parse([
|
||||
'node',
|
||||
'/path/to/frontail',
|
||||
'--pid-path',
|
||||
'/path/to/pid',
|
||||
]);
|
||||
|
||||
daemonize('script', optionsParser);
|
||||
|
||||
|
@ -172,7 +231,12 @@ describe('daemonize', () => {
|
|||
});
|
||||
|
||||
it('should log to file', () => {
|
||||
optionsParser.parse(['node', '/path/to/frontail', '--log-path', '/path/to/log']);
|
||||
optionsParser.parse([
|
||||
'node',
|
||||
'/path/to/frontail',
|
||||
'--log-path',
|
||||
'/path/to/log',
|
||||
]);
|
||||
fs.openSync.returns('file');
|
||||
|
||||
daemonize('script', optionsParser);
|
||||
|
@ -181,7 +245,7 @@ describe('daemonize', () => {
|
|||
fs.openSync.lastCall.args[1].should.equal('a');
|
||||
daemon.daemon.lastCall.args[2].should.eql({
|
||||
stdout: 'file',
|
||||
stderr: 'file'
|
||||
stderr: 'file',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,9 +31,7 @@ describe('serverBuilder', () => {
|
|||
it('should build server accepting requests', () => {
|
||||
const callback = () => {};
|
||||
|
||||
serverBuilder()
|
||||
.use(callback)
|
||||
.build();
|
||||
serverBuilder().use(callback).build();
|
||||
|
||||
createServer.calledWith(callback).should.equal(true);
|
||||
});
|
||||
|
@ -45,9 +43,7 @@ describe('serverBuilder', () => {
|
|||
});
|
||||
|
||||
it('should build server listening on specified port', () => {
|
||||
serverBuilder()
|
||||
.port(6666)
|
||||
.build();
|
||||
serverBuilder().port(6666).build();
|
||||
|
||||
httpServer.listen.calledWith(6666).should.equal(true);
|
||||
});
|
||||
|
@ -59,9 +55,7 @@ describe('serverBuilder', () => {
|
|||
});
|
||||
|
||||
it('should build server listening on specified host', () => {
|
||||
serverBuilder()
|
||||
.host('127.0.0.1')
|
||||
.build();
|
||||
serverBuilder().host('127.0.0.1').build();
|
||||
|
||||
httpServer.listen.calledWith(9001, '127.0.0.1').should.equal(true);
|
||||
});
|
||||
|
@ -81,7 +75,9 @@ describe('serverBuilder', () => {
|
|||
beforeEach(() => {
|
||||
httpsServer = sinon.createStubInstance(https.Server);
|
||||
httpsServer.listen.returns(httpsServer);
|
||||
createHttpsServer = sinon.stub(https, 'createServer').returns(httpsServer);
|
||||
createHttpsServer = sinon
|
||||
.stub(https, 'createServer')
|
||||
.returns(httpsServer);
|
||||
readFileSyncStub = sinon.stub(fs, 'readFileSync');
|
||||
readFileSyncStub.withArgs('key.pem').returns('testkey');
|
||||
readFileSyncStub.withArgs('cert.pem').returns('testcert');
|
||||
|
@ -93,15 +89,13 @@ describe('serverBuilder', () => {
|
|||
});
|
||||
|
||||
it('should build server', () => {
|
||||
const server = serverBuilder()
|
||||
.secure('key.pem', 'cert.pem')
|
||||
.build();
|
||||
const server = serverBuilder().secure('key.pem', 'cert.pem').build();
|
||||
|
||||
server.should.be.an.instanceof(https.Server);
|
||||
createHttpsServer
|
||||
.calledWith({
|
||||
key: 'testkey',
|
||||
cert: 'testcert'
|
||||
cert: 'testcert',
|
||||
})
|
||||
.should.equal(true);
|
||||
});
|
||||
|
@ -109,16 +103,13 @@ describe('serverBuilder', () => {
|
|||
it('should build server accepting requests', () => {
|
||||
const callback = () => {};
|
||||
|
||||
serverBuilder()
|
||||
.use(callback)
|
||||
.secure('key.pem', 'cert.pem')
|
||||
.build();
|
||||
serverBuilder().use(callback).secure('key.pem', 'cert.pem').build();
|
||||
|
||||
createHttpsServer
|
||||
.calledWith(
|
||||
{
|
||||
key: 'testkey',
|
||||
cert: 'testcert'
|
||||
cert: 'testcert',
|
||||
},
|
||||
callback
|
||||
)
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('tail', () => {
|
|||
writeLines(info.fd, 20);
|
||||
|
||||
const tailer = tail(info.path, {
|
||||
buffer: 2
|
||||
buffer: 2,
|
||||
});
|
||||
setTimeout(() => {
|
||||
tailer.getBuffer().should.be.eql(['line18', 'line19']);
|
||||
|
|
|
@ -186,7 +186,7 @@ window.App = (function app(window, document) {
|
|||
Object.keys(_highlightConfig.words).forEach((wordCheck) => {
|
||||
output = output.replace(
|
||||
wordCheck,
|
||||
'<span style="' + _highlightConfig.words[wordCheck] + '">' + wordCheck + '</span>'
|
||||
'<span style="' + _highlightConfig.words[wordCheck] + '">' + wordCheck + '</span>',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ window.App = (function app(window, document) {
|
|||
function() {
|
||||
_isWindowFocused = false;
|
||||
},
|
||||
true
|
||||
true,
|
||||
);
|
||||
window.addEventListener(
|
||||
'focus',
|
||||
|
@ -267,7 +267,7 @@ window.App = (function app(window, document) {
|
|||
_isWindowFocused = true;
|
||||
_faviconReset();
|
||||
},
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
// socket.io init
|
||||
|
@ -340,6 +340,6 @@ window.App = (function app(window, document) {
|
|||
}
|
||||
|
||||
_updateFaviconCounter();
|
||||
}
|
||||
},
|
||||
};
|
||||
}(window, document));
|
||||
|
|
Loading…
Reference in New Issue