forked from garris/ember-backstop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (35 loc) · 1.17 KB
/
index.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
/* eslint-env node */
'use strict';
let bodyParser = require('body-parser');
// if using native backstop remote server
const BACKSTOP_PROXY_PATH = '/backstop';
const BACKSTOP_PROXY_TARGET = 'http://localhost:3000';
module.exports = {
name: 'ember-backstop',
isDevelopingAddon() {
return true;
},
serverMiddleware({ app }) {
// if using native backstop remote server
let proxy = require('http-proxy').createProxyServer({});
proxy.on('error', function(err, req, res) {
console.error(err, req.url);
res.writeHead(500, {
'Content-Type': 'text/plain'
});
res.end(err + ' Please check that backstop-remote service is running.');
});
app.use(BACKSTOP_PROXY_PATH, function(req, res, next) {
proxy.web(req, res, { target: BACKSTOP_PROXY_TARGET });
});
},
includedCommands() {
return {
'backstop:remote': require('./commands/backstop-remote'),
'backstop:approve': require('./commands/backstop-approve'),
'backstop:report': require('./commands/backstop-report'),
'backstop:stop': require('./commands/backstop-stop'),
// 'backstop:test': require('./commands/backstop-test')
};
}
};