Skip to content

Commit 7b52109

Browse files
committed
Added configuration options to the server feature
1 parent a4b5356 commit 7b52109

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

config/chrome.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
"/weather"
1919
],
2020
"outputDir": "shots/bbc",
21-
"maxConnections": 20
21+
"maxConnections": 20,
22+
"server": {
23+
"start": true,
24+
"port": 23423
25+
}
2226
}

lib/gallery.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

3-
var fs = require('fs');
4-
var path = require('path');
5-
var mustache = require('mustache');
6-
var helpers = require('./helpers');
7-
var log = require('./logger');
8-
var connect = require('connect');
3+
var fs = require('fs');
4+
var path = require('path');
5+
var mustache = require('mustache');
6+
var helpers = require('./helpers');
7+
var log = require('./logger');
8+
var connect = require('connect');
99
var serveStatic = require('serve-static');
10-
var open = require('open');
10+
var open = require('open');
1111

12-
module.exports.generate = function(dirs, compareList, outputDir, project, cb) {
12+
module.exports.generate = function(dirs, compareList, outputDir, project, server, cb) {
1313
compareList = compareList.sort(helpers.sortByProp('sort'));
1414
var template = path.join(__dirname, '/../gallery.html');
1515
var view = {
@@ -40,10 +40,13 @@ module.exports.generate = function(dirs, compareList, outputDir, project, cb) {
4040
} else {
4141
log.success('Gallery generated');
4242
cb();
43-
connect().use(serveStatic(outputDir)).listen('9090', function(){
44-
open('http://localhost:9090/gallery.html');
45-
log.success('Server started on port 9090');
46-
});
43+
44+
if(server.start) {
45+
connect().use(serveStatic(outputDir)).listen(server.port, function(){
46+
open('http://localhost:' + server.port + '/gallery.html');
47+
log.success('Server started on port ' + server.port);
48+
});
49+
}
4750
}
4851
});
4952
});

lib/wraith.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ Wraith.prototype.config = function(config) {
5151
self.sizes = [];
5252
self.dirs = [];
5353
self.quiet = config.quiet || false;
54+
self.server = {};
55+
self.server.start = config.server.start || false;
56+
self.server.port = config.server.port || 9090;
5457

5558
if(typeof config.paths !== 'undefined' && config.paths.length > 0 ) {
5659
self.urls = config.paths;
@@ -298,5 +301,5 @@ Wraith.prototype.compareScreenshots = function() {
298301

299302
Wraith.prototype.generateGallery = function() {
300303
var self = this;
301-
gallery.generate(self.dirs, self.compareQueue, self.outputFolder, self.config.project, self.cb);
304+
gallery.generate(self.dirs, self.compareQueue, self.outputFolder, self.config.project, self.server, self.cb);
302305
};

0 commit comments

Comments
 (0)