Skip to content

Commit

Permalink
Docs tweaks, adjust output/tests for noDefaultOutput option
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Jun 1, 2018
1 parent 75859da commit 7ed9b6b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Lead Maintainer - [Devin Ivy](https://github.com/devinivy)
const Hapi = require('hapi');
const AppPlugin = require('./app');

// hpal will look for and use exports.deployment()
// as defined below to obtain a hapi server

exports.deployment = async (start) => {

const server = Hapi.server();
Expand Down Expand Up @@ -154,17 +157,17 @@ A summary of these options can be displayed with the `-h` `--help` flag.
```
$ hpal run debug:curl /user -v

get /user (47ms)
get /user (30ms)

request headers
────────────────────────────────────────────────────────────────────────────────
───────────────────────────────────────────────────────────────────
user-agent shot
host my-computer.local:0
host your-computer.local:0
content-type application/json
content-length 2

response headers
────────────────────────────────────────────────────────────────────────────────
───────────────────────────────────────────────────────────────────
content-type application/json; charset=utf-8
vary origin
cache-control no-cache
Expand All @@ -173,7 +176,7 @@ response headers
connection close

result (200 ok)
────────────────────────────────────────────────────────────────────────────────
───────────────────────────────────────────────────────────────────
{
id: 42,
firstName: 'Paldo',
Expand Down
3 changes: 3 additions & 0 deletions lib/commands/curl.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ module.exports = async (server, args, root, ctx) => {
return options.out.write(rawPayload);
}

output(''); // Make a little room

return output(Util.inspect(result, {
depth: null,
compact: false,
Expand All @@ -93,6 +95,7 @@ module.exports = async (server, args, root, ctx) => {

const display = new internals.Display(ctx, parameters.raw);

output(''); // Make a little room
output(display.title(`${method} ${url}`) + ' ' + display.subheader(`(${timingEnd - timingStart}ms)`));

if (request.payload &&
Expand Down
2 changes: 2 additions & 0 deletions lib/commands/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const internals = {};

module.exports = async (server, args, root, ctx) => {

ctx.output(''); // Make a little room

const repl = Repl.start({
prompt: 'hpal> ',
input: ctx.options.in,
Expand Down
1 change: 1 addition & 0 deletions lib/commands/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = (server, argv, root, ctx) => {

table.push(...rows);

output(''); // Make a little room
output(table.toString());
};

Expand Down
9 changes: 2 additions & 7 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ describe('hpal-debug', () => {

const normalize = (str) => {

return str
.replace('\nRunning debug:curl...\n\n', '')
.replace('\n\nComplete!\n', '')
.replace('\nComplete!\n', ''); // Raw output doesn't have extra newline
return str.trim();
};

const ignoreNewlines = (str) => str.replace(/\s*\n\s*/g, ' ');
Expand Down Expand Up @@ -675,9 +672,7 @@ describe('hpal-debug', () => {

const normalize = (str) => {

return str
.replace('\nRunning debug:routes...\n\n', '')
.replace('\n\nComplete!\n', '');
return str.trim();
};

const unindent = (str) => {
Expand Down

0 comments on commit 7ed9b6b

Please sign in to comment.