@oclif/test 4.0.10 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,6 +24,7 @@ See the [V4 Migration Guide](./MIGRATION.md) if you are migrating from v3 or old
24
24
 
25
25
  - `print` - Print everything that goes to stdout and stderr.
26
26
  - `stripAnsi` - Strip ansi codes from everything that goes to stdout and stderr. Defaults to true.
27
+ - `testNodeEnv` - Sets the `NODE_ENV` value when capturing output. Defaults to `'test'`.
27
28
 
28
29
  See the [tests](./test/capture-output.test.ts) for example usage.
29
30
 
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Errors, Interfaces } from '@oclif/core';
2
2
  type CaptureOptions = {
3
3
  print?: boolean;
4
4
  stripAnsi?: boolean;
5
+ testNodeEnv?: string;
5
6
  };
6
7
  type CaptureResult<T> = {
7
8
  error?: Error & Partial<Errors.CLIError>;
package/lib/index.js CHANGED
@@ -59,6 +59,7 @@ function splitString(str) {
59
59
  async function captureOutput(fn, opts) {
60
60
  const print = opts?.print ?? false;
61
61
  const stripAnsi = opts?.stripAnsi ?? true;
62
+ const testNodeEnv = opts?.testNodeEnv || 'test';
62
63
  const originals = {
63
64
  NODE_ENV: process.env.NODE_ENV,
64
65
  stderr: process.stderr.write,
@@ -86,7 +87,7 @@ async function captureOutput(fn, opts) {
86
87
  };
87
88
  process.stdout.write = mock('stdout');
88
89
  process.stderr.write = mock('stderr');
89
- process.env.NODE_ENV = 'test';
90
+ process.env.NODE_ENV = testNodeEnv;
90
91
  try {
91
92
  const result = await fn();
92
93
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/test",
3
3
  "description": "test helpers for oclif components",
4
- "version": "4.0.10",
4
+ "version": "4.1.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/test/issues",
7
7
  "dependencies": {