Skip to content

Commit

Permalink
Remove execa
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Feb 1, 2020
1 parent e0e2e8f commit da5b943
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"dependencies": {},
"devDependencies": {
"browserify": "^16.0.0",
"execa": "^1.0.0",
"nyc": "^15.0.0",
"prettier": "^1.0.0",
"remark-cli": "^7.0.0",
Expand Down
38 changes: 21 additions & 17 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
var fs = require('fs')
var path = require('path')
var assert = require('assert')
var exec = require('child_process').exec
var PassThrough = require('stream').PassThrough
var test = require('tape')
var execa = require('execa')
var pack = require('../package')
var version = require('../package').version
var stemmer = require('..')

var read = fs.readFileSync
Expand All @@ -28,38 +28,42 @@ test('api', function(t) {

test('cli', function(t) {
var input = new PassThrough()
var help = ['-h', '--help']
var version = ['-v', '--version']
var helps = ['-h', '--help']
var versions = ['-v', '--version']

t.plan(7)

execa.stdout('./cli.js', ['considerations']).then(function(result) {
t.equal(result, 'consider', 'argument')
exec('./cli.js considerations', function(err, stdout, stderr) {
t.deepEqual([err, stdout, stderr], [null, 'consider\n', ''], 'one')
})

execa.stdout('./cli.js', ['detestable', 'vileness']).then(function(result) {
t.equal(result, 'detest vile', 'arguments')
exec('./cli.js detestable vileness', function(err, stdout, stderr) {
t.deepEqual([err, stdout, stderr], [null, 'detest vile\n', ''], 'two')
})

execa.stdout('./cli.js', {input: input}).then(function(result) {
t.equal(result, 'detest vile', 'stdin')
var subprocess = exec('./cli.js', function(err, stdout, stderr) {
t.deepEqual([err, stdout, stderr], [null, 'detest vile\n', ''], 'stdin')
})

input.pipe(subprocess.stdin)
input.write('detestable')

setImmediate(function() {
input.end(' vileness')
})

help.forEach(function(flag) {
execa.stdout('./cli.js', [flag]).then(function(result) {
t.ok(/\s+Usage: stemmer/.test(result), flag)
helps.forEach(function(flag) {
exec('./cli.js ' + flag, function(err, stdout, stderr) {
t.deepEqual(
[err, /\sUsage: stemmer/.test(stdout), stderr],
[null, true, ''],
flag
)
})
})

version.forEach(function(flag) {
execa.stdout('./cli.js', [flag]).then(function(result) {
t.equal(result, pack.version, flag)
versions.forEach(function(flag) {
exec('./cli.js ' + flag, function(err, stdout, stderr) {
t.deepEqual([err, stdout, stderr], [null, version + '\n', ''], flag)
})
})
})

0 comments on commit da5b943

Please sign in to comment.