UNPKG

1.19 kBJavaScriptView Raw
1'use strict';
2
3const express = require('@financial-times/n-internal-tool');
4const fixtures = require('./fixtures.json');
5const chalk = require('chalk');
6const errorHighlight = chalk.bold.red;
7const highlight = chalk.bold.green;
8
9const app = module.exports = express({
10 name: 'public',
11 systemCode: 'n-concept-demo',
12 withFlags: false,
13 withHandlebars: true,
14 withNavigation: false,
15 withAnonMiddleware: false,
16 hasHeadCss: false,
17 demo: true,
18 s3o: false,
19 viewsDirectory: '/demos',
20 layoutsDir: 'demos',
21 partialsDirectory: process.cwd(),
22 directory: process.cwd()
23});
24
25app.get('/', (req, res) => {
26 res.render('demo', Object.assign({
27 title: 'Test App',
28 layout: 'demo-layout',
29 }, fixtures));
30});
31
32function runPa11yTests () {
33 const spawn = require('child_process').spawn;
34 const pa11y = spawn('pa11y-ci');
35
36 pa11y.stdout.on('data', (data) => {
37 console.log(highlight(`${data}`)); //eslint-disable-line
38 });
39
40 pa11y.stderr.on('data', (error) => {
41 console.log(errorHighlight(`${error}`)); //eslint-disable-line
42 });
43
44 pa11y.on('close', (code) => {
45 process.exit(code);
46 });
47}
48
49const listen = app.listen(5005);
50
51if (process.env.PA11Y === 'true') {
52 listen.then(runPa11yTests);
53}