Skip to content
Myr

fix option handling in #15

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

authored by Sindre Sorhus · committed by Sindre Sorhus · parent 605a674 · Browse files · 2 files+9 added−8 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+9 added−8 removed

  • other:+9 added−8 removed

2 files+9 added−8 removed

modified:index.js+3 added-2 removed
modified:test.js+6 added-6 removed
67 unmodified lines
68 process.env.PATH = _path;69});7071test('input option can be a String', async t => {72 const {stdout} = await m('stdin', [], {input: 'foobar'});72 const {stdout} = await m('stdin', {input: 'foobar'});73 t.is(stdout, 'foobar');74});7576test('input option can be a Buffer', async t => {77 const {stdout} = await m('stdin', [], {input: 'testing12'});77 const {stdout} = await m('stdin', {input: 'testing12'});78 t.is(stdout, 'testing12');79});8081test('input can be a Stream', async t => {82 var s = new stream.PassThrough();83 s.write('howdy');84 s.end();85 const {stdout} = await m('stdin', [], {input: s});85 const {stdout} = await m('stdin', {input: s});86 t.is(stdout, 'howdy');87});8889test('input option can be a String - sync', async t => {90 const stdout = m.sync('stdin', [], {input: 'foobar'});90 const stdout = m.sync('stdin', {input: 'foobar'});91 t.is(stdout, 'foobar');92});9394test('input option can be a Buffer - sync', async t => {95 const stdout = m.sync('stdin', [], {input: new Buffer('testing12', 'utf8')});95 const stdout = m.sync('stdin', {input: new Buffer('testing12', 'utf8')});96 t.is(stdout, 'testing12');97});9899test('helpful error trying to provide an input stream in sync mode', t => {100 t.throws(101 () => m.sync('stdin', [], {input: new stream.PassThrough()}),101 () => m.sync('stdin', {input: new stream.PassThrough()}),102 /The `input` option cannot be a stream in sync mode/103 );104});105
5 unmodified lines