Comparing version 0.3.0 to 0.4.0
17
index.js
@@ -9,3 +9,6 @@ 'use strict'; | ||
opts = Object.assign({silent: true}, opts); | ||
opts = Object.assign({ | ||
silent: true, | ||
once: false | ||
}, opts); | ||
@@ -15,5 +18,13 @@ const std = process[type]; | ||
const unhook = () => { | ||
std.write = write; | ||
}; | ||
std.write = (str, enc, cb2) => { | ||
const cbRet = cb(str, enc); | ||
if (opts.once) { | ||
unhook(); | ||
} | ||
if (opts.silent) { | ||
@@ -27,5 +38,3 @@ return typeof cbRet === 'boolean' ? cbRet : true; | ||
return () => { | ||
std.write = write; | ||
}; | ||
return unhook; | ||
} | ||
@@ -32,0 +41,0 @@ |
{ | ||
"name": "hook-std", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Hook and modify stdout/stderr", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -58,2 +58,9 @@ # hook-std [![Build Status](https://travis-ci.org/sindresorhus/hook-std.svg?branch=master)](https://travis-ci.org/sindresorhus/hook-std) | ||
##### once | ||
Type: `boolean`<br> | ||
Default: `false` | ||
Automatically unhooks after the first call. | ||
##### callback | ||
@@ -60,0 +67,0 @@ |
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
3923
38
75