{"name":"coffee","version":"4.2.1","description":"Test command line on nodejs","main":"index.js","dependencies":{"cross-spawn":"^6.0.5","debug":"^3.1.0"},"devDependencies":{"autod":"^3.0.1","egg-ci":"^1.8.0","eslint":"^3.19.0","eslint-config-egg":"^4.1.0","mm":"^2.2.2","mocha":"2","nyc":"^11.0.2","spy":"^1.0.0"},"repository":{"type":"git","url":"git://github.com/node-modules/coffee.git"},"homepage":"https://github.com/node-modules/coffee","author":{"name":"popomore","email":"sakura9515@gmail.com"},"keywords":["test","shell","spawn","fork","child_process","exec"],"license":"MIT","engines":{"node":">= 4.0.0"},"ci":{"version":"4, 6, 8"},"scripts":{"autod":"autod","lint":"eslint .","test":"mocha -R spec -t 80000 test/*.js","cov":"nyc -r json -r lcov -r text-summary npm test","ci":"npm run lint && npm run cov"},"publishConfig":{"tag":"latest-4"},"readme":"# Coffee\n\nTest command line on Node.js.\n\n---\n\n[![NPM version](https://img.shields.io/npm/v/coffee.svg?style=flat)](https://npmjs.org/package/coffee)\n[![Build Status](https://img.shields.io/travis/node-modules/coffee.svg?style=flat)](https://travis-ci.org/node-modules/coffee)\n[![codecov.io](https://img.shields.io/codecov/c/github/node-modules/coffee.svg?style=flat)](http://codecov.io/github/node-modules/coffee?branch=master)\n[![NPM downloads](http://img.shields.io/npm/dm/coffee.svg?style=flat)](https://npmjs.org/package/coffee)\n\n## Install\n\n```\n$ npm install coffee -g\n```\n\n## Usage\n\nCoffee is useful for test command line in test frammework (like Mocha).\n\n```js\ndescribe('cat', function() {\n  it('should concat input', function(done) {\n    var coffee = require('coffee');\n    coffee.spawn('cat')\n    .write('1')\n    .write('2')\n    .expect('stdout', '12')\n    .expect('code', 0)\n    .end(done);\n  })\n})\n```\n\nYou can also use fork for spawning Node processes.\n\n```js\ncoffee.fork('/path/to/file.js', ['args '])\n.expect('stdout', '12\\n')\n.expect('stderr', '34\\n')\n.expect('code', 0)\n.end(done);\n```\n\nIn file.js\n\n```js\nconsole.log(12);\nconsole.error(34);\n```\n\n## Support multiple process coverage with nyc\n\nRecommend to use [nyc] for coverage, you can use [any test frammework supported by nyc](https://istanbul.js.org/docs/tutorials/).\n\n## API\n\n### coffee.spawn\n\nRun command using `child_process.spawn`, then return `Coffee` instance.\n\nArguments see [child_process.spawn](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)\n\n### coffee.fork\n\nRun command using `child_process.fork`, then return `Coffee` instance.\n\nArguments see [child_process.fork](http://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options)\n\n### Coffee\n\nAssertion object\n\n#### coffee.expect(type, expected)\n\nAssert type with expected value, expected value can be string, regular expression, and array.\n\n```js\ncoffee.spawn('echo', ['abcdefg'])\n.expect('stdout', 'abcdefg')\n.expect('stdout', /^abc/)\n.expect('stdout', ['abcdefg', /abc/])\n.end(done);\n```\n\nAccept type: `stdout`, `stderr`, `code`, `error`\n\n#### coffee.notExpect(type, expected)\n\nThe opposite assertion of `expect`.\n\n#### coffee.write(data)\n\nWrite data to stdin, see example above.\n\n#### coffee.waitForPrompt(bool)\n\nIf you set false, coffee will write stdin immediately, otherwise will wait for `prompt` message.\n\n```js\ncoffee.fork('/path/to/cli', ['abcdefg'])\n.waitForPrompt()\n.write('tz\\n')\n.write('2\\n');\n.end(done);\n```\n\ncli process should emit `prompt` message:\n\n```js\nconst readline = require('readline');\n\nconst rl = readline.createInterface({\n  input: process.stdin,\n  output: process.stdout\n});\n\nfunction ask(q, callback) {\n  process.send({ type: 'prompt' });\n  rl.question(q, callback);\n}\n\nask('What\\'s your name? ', answer => {\n  console.log(`hi, ${answer}`);\n  ask('How many coffee do you want? ', answer => {\n    console.log(`here is your ${answer} coffee`);\n    rl.close();\n  });\n});\n```\n\n#### coffee.end(callback)\n\nCallback will be called after completing the assertion, the first argument is Error if throw exception.\n\n#### coffee.debug(level)\n\nWrite data to process.stdout and process.stderr for debug\n\n`level` can be\n\n- 0 (default): pipe stdout + stderr\n- 1: pipe stdout\n- 2: pipe stderr\n- false: disable\n\nAlternative you can use `COFFEE_DEBUG` env.\n\n#### coffee.coverage()\n\nIf you set false, coffee will not generate coverage.json, default: true.\n\n#### coffee.beforeScript(scriptFile)\n\nAdd a hook script before fork child process run.\n\n## LISENCE\n\nCopyright (c) 2017 node-modules. Licensed under the MIT license.\n\n\n[nyc]: https://github.com/istanbuljs/nyc\n","readmeFilename":"README.md","gitHead":"a530c2d846c49db18bd977646ab2895c55dd3824","bugs":{"url":"https://github.com/node-modules/coffee/issues"},"_id":"coffee@4.2.1","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"integrity":"sha512-j6S0LmVUjxAFoLhcmcTSawRGLVY71nLY4mGn/JmFhalQwkGB/lhMJRXcTn17NuE3YB3xK5YXUgB3LtE8FNBYSA==","shasum":"4027330311b23d11ae6621ffb70ba9c132e647ce","tarball":"http://registry-npm.ywwl.com/coffee/download/coffee-4.2.1.tgz","fileCount":8,"unpackedSize":18395,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbrdyUCRA9TVsSAnZWagAAkdkP/AqMjL3KtuZPj2oisgQL\njkOBtXshXbDhPyBbE8farCqU0grNw/+BCCyk111ObikNjMZLovxPWiP4vaie\ndKN9PY9sOXTXs0hT5XTkEgS5ZF4PVxNRtJ3ZBDqHFqsVl87c9pgE/Lct09Lr\nRvB6BrSZHplP1h0UZ8WTg7E/TWQQua7XFamT/PmWjAW+aBaiIZ4iH5eIWCzv\nFHQhd+LHbHi1X5zOF5MTsCWiEfncwbLaJ/GAHzd5F1m0GLGHwLsr/eYPReYr\n+qnJ/DlgEJFLEMfB0a28V7x1RCPmAW6sL4mvNTj4htZpPbQwc+UWJwGx9N7j\nEtEcAfce73RyVIwm55qP+q2PtTJ4D9cHxzhK+VIXhCqbc/CTfWCSI6915dqi\nVAmIZh+T2wbddqoZhoQ7xe/1KBVRob+8xv+va8h6hlVTQcwq+i07UUHHbIip\nIi2+0DTSpSMO9OJyTSTZ7kxTr6irtCmQb0QnGKeXrOjan5PDIUgsJ5SurniZ\noQDpIHdDjUn8E2Fy6dw/lZQhjpjPYU1cpHDtWIAuEfXZQpcxGAtEjDMndudW\n7GebrI7soxZlTEmD9816Z4ex7UGXfAL7M9scYTSUCpHsjBAjwiwHMzkI9XIM\nxQJxbgN62ALENPc/E8I2VqiexvSuB186K1z5tcCDwO6jHIe3YQXmuh1qZmEZ\nyVFX\r\n=kb4i\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCWXq8mhZbLZ7lka3Gi8aA7yWG+JxfkdUPPpd6rvNUcKgIhAJo5c6LXJlykgM7nsZZH8WgiZYSVYT/1L6oNgV2RyfeU"}],"size":6258,"noattachment":false,"key":"/coffee/-/coffee-4.2.1.tgz"},"maintainers":[{"email":"atian25@qq.com","name":"atian25"},{"email":"fengmk2@gmail.com","name":"fengmk2"},{"email":"sakura9515@gmail.com","name":"popomore"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/coffee_4.2.1_1538120851525_0.12432680574703636"},"_hasShrinkwrap":false,"publish_time":1538120851694,"_cnpm_publish_time":1538120851694,"dist-tags":{"latest":"5.5.1","latest-3":"3.3.3","latest-4":"4.2.1"}}