Skip to content

Commit

Permalink
added cli
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz-io committed Oct 1, 2016
1 parent e19e341 commit 8c62b3e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
15 changes: 15 additions & 0 deletions lib/cli.js
@@ -1 +1,16 @@
#!/usr/bin/env node

const vfs = require('vinyl-fs')
const through = require('through2')
const signer = require('./signer')

const [root, ...globs] = process.argv.slice(2)

process.chdir(root)

vfs.src([...globs, '!verified_contents.json', '!payload.json'])
.pipe(signer())
.pipe(through.obj((file, enc, cb) => {
process.stdout.write(file.contents)
cb()
}))
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -51,7 +51,8 @@
"duplexer2": "^0.1.4",
"node-rsa": "^0.4.2",
"through2": "^2.0.1",
"vinyl": "^2.0.0"
"vinyl": "^2.0.0",
"vinyl-fs": "^2.4.3"
},
"devDependencies": {
"ava": "^0.16.0",
Expand All @@ -60,7 +61,6 @@
"open": "0.0.5",
"pre-push": "^0.1.1",
"tempfile": "^1.1.1",
"vinyl-fs": "^2.4.3",
"xo": "^0.16.0"
},
"xo": {
Expand Down
29 changes: 28 additions & 1 deletion test/lib/cli.js
@@ -1,3 +1,30 @@
import {exec} from 'child_process'
import path from 'path'
import test from 'ava'

test.todo('cli')
const testCli = ({t, root, glob, result}) =>
new Promise((resolve, reject) => {
const cli = path.resolve(__dirname, '../../lib/cli.js')
const proc = exec(`node ${cli} ${root} ${glob}`)
const buff = []

proc.stdout.on('data', buff.push.bind(buff))

proc.stderr.on('data', reject)

proc.on('error', reject)

proc.on('close', err => {
if (err) {
return reject(err)
}
t.deepEqual(JSON.parse(buff.join('')), result)
resolve()
})
})

test('calculate verified contents for signer fixtures', t => testCli({t,
root: path.resolve(__dirname, '../fixtures/signer'),
glob: '\'*\'',
result: require('../fixtures/signer/verified_contents.json'),
}))

0 comments on commit 8c62b3e

Please sign in to comment.