Skip to content

Commit

Permalink
refactor and add -c alias for all commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoffer Åström committed Nov 8, 2017
1 parent e203fb5 commit 7c0c72a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/cdp/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const path = require('path');
const Koa = require('koa');
const serve = require('koa-static');
const favicon = require('koa-favicon');
const instrument = require('./instrument');
const transform = require('./transform');

module.exports = function createHttpServer(files, exclude, coverage, coverageExclude, httpOpts) {
const app = new Koa();
app.use(favicon(path.resolve(__dirname, '../../aw.png')));
app.use(instrument(files, exclude, coverage, coverageExclude));
app.use(transform(files, exclude, coverage, coverageExclude));
app.use(...httpOpts.root.map(root => serve(path.resolve(process.cwd(), root))));
return app.listen(httpOpts.port);
};
1 change: 1 addition & 0 deletions src/cdp/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
description: 'Path to config file',
type: 'string',
default: 'aw.config.js',
alias: 'c',
},
url: {
description: 'Url to html file',
Expand Down
6 changes: 3 additions & 3 deletions src/cdp/instrument.js → src/cdp/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ function transformFile(filePath, coverage) {
});
};
}
function transform(filePath, coverage) {
function transformify(filePath, coverage) {
return new Promise(transformFile(filePath, coverage));
}

module.exports = function instrument(files, exclude, coverage, coverageExclude) {
module.exports = function transform(files, exclude, coverage, coverageExclude) {
const shouldInstrument = url => (coverage ?
coverageExclude.shouldInstrument(url) :
exclude.shouldInstrument(url));
Expand All @@ -41,7 +41,7 @@ module.exports = function instrument(files, exclude, coverage, coverageExclude)
const url = request.url.substring(1);
if (shouldInstrument(url)) {
const filePath = path.relative(process.cwd(), url);
response.body = await transform(filePath, coverage);
response.body = await transformify(filePath, coverage);
}
};
};
1 change: 1 addition & 0 deletions src/node/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
description: 'Path to config file',
type: 'string',
default: 'aw.config.js',
alias: 'c',
},
glob: {
description: 'Glob pattern',
Expand Down
1 change: 1 addition & 0 deletions src/protractor/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
description: 'Path to config file',
type: 'string',
default: 'aw.config.js',
alias: 'c',
},
glob: {
description: 'Glob pattern',
Expand Down
1 change: 1 addition & 0 deletions src/puppeteer/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
description: 'Path to config file',
type: 'string',
default: 'aw.config.js',
alias: 'c',
},
glob: {
description: 'Glob pattern',
Expand Down

0 comments on commit 7c0c72a

Please sign in to comment.