Comparing version 4.1.0 to 4.2.0
'use strict' | ||
const fs = require('fs') | ||
const { PassThrough, pipeline } = require('readable-stream') | ||
const { PassThrough, Writable, pipeline } = require('stream') | ||
const glob = require('glob') | ||
const process = require('process') | ||
@@ -21,2 +22,10 @@ const defaults = { | ||
function createDefaultStream () { | ||
return new Writable({ | ||
write (chunk, encoding, callback) { | ||
process.stdout.write(chunk, callback) | ||
} | ||
}) | ||
} | ||
function helpMe (opts) { | ||
@@ -98,3 +107,3 @@ opts = Object.assign({}, defaults, opts) | ||
opts = opts || {} | ||
const stream = opts.stream || process.stdout | ||
const stream = opts.stream || createDefaultStream() | ||
const _onMissingHelp = opts.onMissingHelp || onMissingHelp | ||
@@ -101,0 +110,0 @@ return new Promise((resolve, reject) => { |
{ | ||
"name": "help-me", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Help command for node, partner of minimist and commist", | ||
@@ -29,2 +29,3 @@ "main": "help-me.js", | ||
"pre-commit": "^1.1.3", | ||
"proxyquire": "^2.1.3", | ||
"standard": "^16.0.0", | ||
@@ -31,0 +32,0 @@ "tap-spec": "^5.0.0", |
29
test.js
@@ -6,4 +6,6 @@ 'use strict' | ||
const fs = require('fs') | ||
const os = require('os') | ||
const path = require('path') | ||
const helpMe = require('./') | ||
const proxyquire = require('proxyquire') | ||
@@ -321,1 +323,28 @@ test('throws if no directory is passed', function (t) { | ||
}) | ||
test('should allow for awaiting the response with default stdout stream', async function (t) { | ||
t.plan(2) | ||
const _process = Object.create(process) | ||
const stdout = Object.create(process.stdout) | ||
Object.defineProperty(_process, 'stdout', { | ||
value: stdout | ||
}) | ||
let completed = false | ||
stdout.write = (data, cb) => { | ||
t.equal(data.toString(), 'hello world' + os.EOL) | ||
completed = true | ||
cb() | ||
} | ||
const helpMe = proxyquire('./help-me', { | ||
process: _process | ||
}) | ||
await helpMe.help({ | ||
dir: 'fixture/basic' | ||
}) | ||
t.ok(completed) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15254
416
7