Skip to content

Commit

Permalink
Apply 'standard' to test/cli.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pjohnmeyer authored and isaacs committed Oct 12, 2018
1 parent 8bcd207 commit 824e08a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/cli.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
'use strict'
var t = require('tap');
var t = require('tap')

const spawn = require('child_process').spawn
const bin = require.resolve('../bin/semver')
const run = args => new Promise((res, rej) => {
const run = args => new Promise((resolve, reject) => {
const c = spawn(process.execPath, [bin].concat(args))
c.on('error', rej)
c.on('error', reject)
const out = []
const err = []
c.stdout.setEncoding('utf-8')
c.stdout.on('data', chunk => out.push(chunk))
c.stderr.setEncoding('utf-8')
c.stderr.on('data', chunk => err.push(chunk))
c.on('close', (code, signal) => {
res({
resolve({
out: out.join(''),
err: err.join(''),
code: code,
Expand All @@ -22,13 +22,10 @@ const run = args => new Promise((res, rej) => {
})
})

const runTest = (t, args, expect) =>
run(args).then(actual => t.match(actual, expect))

t.test('inc tests', t => {
[
[['-i', 'major', '1.0.0'], { out: '2.0.0', code: 0, signal: null }],
[['-i', 'major', '1.0.0', '1.0.1'], { out: '', err: '--inc can only be used on a single version with no range', code: 1 }]
].forEach(c => t.resolveMatch(run(c[0]), c[1]))
t.end()
});
})

0 comments on commit 824e08a

Please sign in to comment.