1 | 'use strict';
|
2 |
|
3 | const express = require('@financial-times/n-internal-tool');
|
4 | const fixtures = require('./fixtures.json');
|
5 | const chalk = require('chalk');
|
6 | const errorHighlight = chalk.bold.red;
|
7 | const highlight = chalk.bold.green;
|
8 |
|
9 | const 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 |
|
25 | app.get('/', (req, res) => {
|
26 | res.render('demo', Object.assign({
|
27 | title: 'Test App',
|
28 | layout: 'demo-layout',
|
29 | }, fixtures));
|
30 | });
|
31 |
|
32 | function 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}`));
|
38 | });
|
39 |
|
40 | pa11y.stderr.on('data', (error) => {
|
41 | console.log(errorHighlight(`${error}`));
|
42 | });
|
43 |
|
44 | pa11y.on('close', (code) => {
|
45 | process.exit(code);
|
46 | });
|
47 | }
|
48 |
|
49 | const listen = app.listen(5005);
|
50 |
|
51 | if (process.env.PA11Y === 'true') {
|
52 | listen.then(runPa11yTests);
|
53 | }
|