Skip to content
Myr

Make .configureOutput() create copy of settings instead of in-place change (#2350)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent 672e380 · Browse files · 2 files+16 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−1 removed

  • tests:+11 added−0 removed
  • other:+5 added−1 removed

2 files+16 added−1 removed

modified:lib/command.js+5 added-1 removed
237 unmodified lines
238239 configureOutput(configuration) {240 if (configuration === undefined) return this._outputConfiguration;241242 Object.assign(this._outputConfiguration, configuration);242 this._outputConfiguration = Object.assign(243 {},244 this._outputConfiguration,245 configuration,246 );247 return this;248 }249250 /**
2416 unmodified lines
modified:tests/command.configureOutput.test.js+11 added
327 unmodified lines
328 writeErr,329 );330});331332test('when configureOutput after copyInheritedSettings then original unchanged', () => {333 const program = new commander.Command();334 program.configureOutput({ getOutHelpWidth: () => 80 });335 const copy = program.createCommand('copy');336 copy.copyInheritedSettings(program);337 expect(copy.configureOutput().getOutHelpWidth()).toBe(80);338 copy.configureOutput({ getOutHelpWidth: () => 40 });339 expect(copy.configureOutput().getOutHelpWidth()).toBe(40);340 expect(program.configureOutput().getOutHelpWidth()).toBe(80);341});342343describe.each([['getOutHasColors'], ['getErrHasColors']])(344 '%s',345 (configProperty) => {346 // Tried and failed to mock/modify process.stdout.isTTY to test that part of implementation.
19 unmodified lines