Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coffee

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coffee - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

lib/assert.js

2

HISTORY.md

@@ -5,4 +5,4 @@ # History

## 0.1.0
## 1.0.0
First commit
'use strict';
module.exports = function() {
return '';
var Coffee = require('./lib/coffee');
exports.Coffee = Coffee;
exports.fork = function(modulePath, args, opt) {
return new Coffee({
method: 'fork',
cmd: modulePath,
args: args,
opt: opt
});
};
exports.spawn = function(cmd, args, opt) {
return new Coffee({
method: 'spawn',
cmd: cmd,
args: args,
opt: opt
});
};
{
"name": "coffee",
"version": "0.1.0",
"description": "The best module ever.",
"version": "1.0.0",
"description": "Test command line on nodejs",
"main": "index",
"dependencies": {},
"dependencies": {
"debug": "~2.1.1"
},
"devDependencies": {
"coveralls": "2",
"istanbul": "0",
"jshint": "*",
"istanbul": "0",
"coveralls": "2",
"mocha": "1",
"should": "4"
"should": "~4.6.0"
},

@@ -20,2 +22,10 @@ "repository": {

"author": "popomore <sakura9515@gmail.com>",
"keywords": [
"test",
"shell",
"spawn",
"fork",
"child_process",
"exec"
],
"license": "MIT",

@@ -22,0 +32,0 @@ "scripts": {

@@ -1,2 +0,2 @@

# coffee
# Coffee

@@ -8,9 +8,9 @@ [![NPM version](https://img.shields.io/npm/v/coffee.svg?style=flat)](https://npmjs.org/package/coffee)

The best module ever.
Test command line on nodejs
---
```
## Install
```
$ npm install coffee -g

@@ -21,8 +21,77 @@ ```

Coffee is useful to test command line in Mocha or other test frammework.
```
var coffee = require('coffee');
describe('cat', function() {
it('should concat input', function(done) {
var coffee = require('coffee');
coffe.spawn('cat')
.write('1')
.write('2')
.expect('stdout', '12')
.expect('code', 0)
.end(done);
})
})
```
You can also use fork for spawning Node processes.
```
coffe.fork('/path/to/file.js', ['args '])
.expect('stdout', '12\n')
.expect('stderr', '34\n')
.expect('code', 0)
.end(done);
```
In file.js
```
console.log(12);
console.log(34);
```
## API
### coffee.spawn
Run command using `child_process.spawn`, then return `Coffee` instance.
Arguments see [child_process.spawn](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)
### coffee.fork
Run command using `child_process.fork`, then return `Coffee` instance.
Arguments see [child_process.fork](http://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options)
### Coffee
Assertion object
#### coffee.expect(type, expected)
Assert type with expected value, expected value can be string, regular expression, and array.
```
coffe.spawn('echo', ['abcdefg'])
.expect('stdout', 'abcdefg')
.expect('stdout', /^abc/)
.expect('stdout', ['abcdefg', /abc/])
.end(done);
```
Accept type: `stdout`, `stderr`, `code`
#### coffee.write(data)
Write data to stdin, see example above.
#### coffee.end(callback)
Callback will be called after completing the assertion, the first argument is Error if throw exception.
## LISENCE
Copyright (c) 2015 popomore. Licensed under the MIT license.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc