{"_id":"spawn-mock","_rev":"3-d1fa27c3cd4505f4f3df762cdf699f88","name":"spawn-mock","description":"Simple mock for child_process.spawn","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"spawn-mock","version":"1.0.0","description":"Simple mock for child_process.spawn","main":"lib/commonjs","scripts":{"test:lint":"tslint src/**/*.ts src/*.ts","test:unit":"TS_NODE_PROJECT=test/tsconfig.json mocha -r ts-node/register test/*.ts","test":"npm run test:lint && npm run test:unit","commit":"git-cz","changelog":"conventional-changelog --infile CHANGELOG.md --same-file --release-count 0 --preset angular","postchangelog":"git add CHANGELOG.md && git commit -m 'docs(CHANGELOG): append to changelog'","build:es2015":"tsc -P tsconfig.json","build:commonjs":"tsc -P tsconfig.commonjs.json","build":"npm run build:es2015 && npm run build:commonjs","preversion":"npm run build","postversion":"npm run changelog && git push origin master --tags && npm publish","release:minor":"npm version minor -m 'chore(package): v%s'","release:major":"npm version major -m 'chore(package): v%s'"},"repository":{"type":"git","url":"git+https://github.com/TylorS/spawn-mock.git"},"keywords":["node","mock","child_process","spawn"],"author":{"name":"Tylor Steinberger","email":"tlsteinberger167@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/TylorS/spawn-mock/issues"},"homepage":"https://github.com/TylorS/spawn-mock#readme","config":{"ghooks":{"commit-msg":"node ./node_modules/.bin/validate-commit-msg"}},"jsnext:main":"lib/es2015/index.js","module":"lib/es2015/index.js","typings":"lib/es2015/index.d.ts","devDependencies":{"@motorcycle/tslint":"^1.2.0","@types/mocha":"^2.2.33","@types/node":"0.0.3","commitizen":"^2.8.6","conventional-changelog-cli":"^1.2.0","cz-conventional-changelog":"^1.2.0","ghooks":"^1.3.2","mocha":"^3.2.0","ts-node":"^1.7.2","tslint":"^4.0.2","typescript":"^2.1.4","validate-commit-msg":"^2.8.2"},"dependencies":{"stdio-mock":"^1.1.0"},"gitHead":"9d2e62f6bd780b1bba10ffad32b2279ffb419da3","_id":"spawn-mock@1.0.0","_shasum":"451f9b10045288abda63b844c2cec380e47721d9","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.1.0","_npmUser":{"name":"tylors","email":"tlsteinberger167@gmail.com"},"dist":{"shasum":"451f9b10045288abda63b844c2cec380e47721d9","tarball":"https://registry.npmjs.org/spawn-mock/-/spawn-mock-1.0.0.tgz","integrity":"sha512-jV/GrvGZpvCfDlqbbamtFvPpQcwTtqb0NZCNdx0g/20RIYrQlo8j14swjnYL9LIaiDyPMm3UrKN/1cET2myebw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFPuxVOxrV71shvQq+lI4CBEOgF0ZP2+W7TOHRbuk+3EAiBmedWke95amQRhIDs9KeiDfTQt/YsK4BmJsr00mvWXKg=="}]},"maintainers":[{"name":"tylors","email":"tlsteinberger167@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/spawn-mock-1.0.0.tgz_1481683949449_0.5303463824093342"}}},"readme":"# spawn-mock\n\n> Simple mock for child_process.spawn\n\nThis is a basic mock for child_process.spawn built on top of\n[`stdio-mock`](https://github.com/TylorS/stdio-mock), if you wish to use this\nlibrary, it will likely be very helpful to learn its API for `MockReadable` and\n`MockWritable`.\n\n## Let me have it!\n```sh\nnpm install --save spawn-mock\n```\n\n## API\n\n#### `mockSpawn(callback: (mockChildProcess: MockChildProcess) => any): Spawn`\n\nThe only function exported by this library takes a callback that allows you to\nimperatively call methods on to \"mock\" an actual called child process.\n\n**Example:**\n\n```typescript\nimport { mockSpawn } from 'spawn-mock';\n\nconst spawn = mockSpawn(function (cp: MockChildProcess) {\n  // the command (cmd) and the arguments (args) that the returned function\n  // has bene called wth\n  const { cmd, args } = cp;\n\n  // write the arguments to the standard output\n  cp.stdout.write(args.join(' '));\n\n  // end the child process\n  cp.end();\n})\n\nconst cp = spawn('echo', ['hello']);\n\ncp.stdout.on('data', data => console.log(data.toString())) // 'hello'\n\n// left as an exercise for the reader ;)\n```\n\n## Types\n\n#### `Spawn`\n\n```typescript\nexport type Spawn =\n  (cmd: string, args: string[], options?: SpawnOptions | undefined) => MockChildProcess\n```\n\n#### `MockChildProcess`\n```typescript\nimport { SpawnOptions, ChildProcess } from 'child_process';\nimport { MockWritable, MockReadable } from 'stdio-mock';\n\nexport declare class MockChildProcess extends MockWritable implements ChildProcess {\n    stdin: MockWritable;\n    stdout: MockReadable;\n    stderr: MockReadable;\n    stdio: [MockWritable, MockReadable, MockReadable];\n    pid: number;\n    connected: boolean;\n    cmd: string;\n    args: Array<string>;\n    options: SpawnOptions | undefined;\n\n    constructor(cmd: string, args: Array<string>, options?: SpawnOptions);\n\n    end(): void;\n    disconnect(): void;\n    kill(signal?: string, code?: number): void;\n    send(message: any): boolean;\n    unref(): void;\n    ref(): void;\n}\n```","maintainers":[{"name":"tylors","email":"tlsteinberger167@gmail.com"}],"time":{"modified":"2022-06-26T22:38:35.950Z","created":"2016-12-14T02:52:30.085Z","1.0.0":"2016-12-14T02:52:30.085Z"},"homepage":"https://github.com/TylorS/spawn-mock#readme","keywords":["node","mock","child_process","spawn"],"repository":{"type":"git","url":"git+https://github.com/TylorS/spawn-mock.git"},"author":{"name":"Tylor Steinberger","email":"tlsteinberger167@gmail.com"},"bugs":{"url":"https://github.com/TylorS/spawn-mock/issues"},"license":"MIT","readmeFilename":"README.md"}