z85-cli
Advanced tools
Comparing version 0.1.9 to 0.3.0
#!/usr/bin/env node | ||
/*jslint node: true */ | ||
'use strict'; | ||
/* jslint node: true */ | ||
'use strict' | ||
var lib = require('../lib/z85-cli'); | ||
var lib = require('../lib/z85-cli') | ||
var userArgs = process.argv.slice(2), | ||
mode = userArgs[0], | ||
value = userArgs[1]; | ||
var userArgs = process.argv.slice(2) | ||
var mode = userArgs[0] | ||
var value = userArgs[1] | ||
try { | ||
console.log(lib.z85cli(mode, value)); | ||
} catch (error) { | ||
console.error(error.message); | ||
} | ||
try { | ||
console.log(lib.z85cli(mode, value)) | ||
} catch (error) { | ||
console.error(error.message) | ||
} |
@@ -1,35 +0,18 @@ | ||
/*jslint node: true */ | ||
'use strict'; | ||
/* jslint node: true */ | ||
'use strict' | ||
module.exports = function (grunt) { | ||
// Project configuration. | ||
grunt.initConfig({ | ||
nodeunit: { | ||
files: ['test/**/*_test.js'] | ||
}, | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc' | ||
}, | ||
gruntfile: { | ||
src: 'Gruntfile.js' | ||
}, | ||
lib: { | ||
src: ['lib/**/*.js'] | ||
}, | ||
test: { | ||
src: ['test/**/*.js'] | ||
} | ||
} | ||
}); | ||
grunt.initConfig({ | ||
nodeunit: { | ||
files: ['test/**/*_test.js'] | ||
} | ||
}) | ||
// These plugins provide necessary tasks. | ||
grunt.loadNpmTasks('grunt-contrib-nodeunit'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-nodeunit') | ||
// Default task. | ||
grunt.registerTask('test', ['nodeunit']); | ||
grunt.registerTask('default', ['jshint', 'test']); | ||
}; | ||
grunt.registerTask('test', ['nodeunit']) | ||
grunt.registerTask('default', ['test']) | ||
} |
@@ -1,37 +0,37 @@ | ||
/*jslint node: true */ | ||
'use strict'; | ||
/* jslint node: true */ | ||
'use strict' | ||
var z85 = require('z85'); | ||
var z85 = require('z85') | ||
var z85cli = function (mode, value) { | ||
if (mode && value) { | ||
if (mode === '--encode' || mode === '-e') { | ||
var encoded = z85.encode(value); | ||
if (encoded) { | ||
return encoded; | ||
} else { | ||
throw new Error('Input cannot be z85 encoded. See http://rfc.zeromq.org/spec:32'); | ||
} | ||
} else if (mode === '--decode' || mode === '-d') { | ||
var decoded = z85.decode(value); | ||
if (decoded) { | ||
decoded = decoded.toString(); | ||
return decoded; | ||
} else { | ||
throw new Error('Input not recognized as z85 encoded. See http://rfc.zeromq.org/spec:32'); | ||
} | ||
} else { | ||
throw logDocumentation(); | ||
} | ||
if (mode && value) { | ||
if (mode === '--encode' || mode === '-e') { | ||
var encoded = z85.encode(value) | ||
if (encoded) { | ||
return encoded | ||
} else { | ||
throw new Error('Input cannot be z85 encoded. See http://rfc.zeromq.org/spec:32') | ||
} | ||
} else if (mode === '--decode' || mode === '-d') { | ||
var decoded = z85.decode(value) | ||
if (decoded) { | ||
decoded = decoded.toString() | ||
return decoded | ||
} else { | ||
throw new Error('Input not recognized as z85 encoded. See http://rfc.zeromq.org/spec:32') | ||
} | ||
} else { | ||
throw logDocumentation(); | ||
throw logDocumentation() | ||
} | ||
}; | ||
} else { | ||
throw logDocumentation() | ||
} | ||
} | ||
function logDocumentation() { | ||
return new Error('\nRun options:\n' + | ||
function logDocumentation () { | ||
return new Error('\nRun options:\n' + | ||
' `z85 --encode [-e] <value>`\n' + | ||
' `z85 --decode [-d] <value>`'); | ||
' `z85 --decode [-d] <value>`') | ||
} | ||
exports.z85cli = z85cli; | ||
exports.z85cli = z85cli |
{ | ||
"name": "z85-cli", | ||
"description": "Command line client for ZeroMQ Base-85 encoding", | ||
"version": "0.1.9", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/bkimminich/z85-cli", | ||
@@ -22,3 +22,3 @@ "author": { | ||
"scripts": { | ||
"test": "grunt", | ||
"test": "standard && grunt", | ||
"coveralls": "jscoverage lib && Z85_CLI_COVERAGE=1 nodeunit --reporter=lcov test | coveralls", | ||
@@ -31,9 +31,9 @@ "codeclimate": "jscoverage lib && Z85_CLI_COVERAGE=1 nodeunit --reporter=lcov test | codeclimate-test-reporter" | ||
"devDependencies": { | ||
"nodeunit": "~0.10", | ||
"nodeunit": "~0.11", | ||
"jscoverage": "~0.6", | ||
"coveralls": "~2.11", | ||
"coveralls": "~3.0", | ||
"grunt": "~1.0", | ||
"grunt-contrib-jshint": "~1.0", | ||
"grunt-contrib-nodeunit": "~1.0", | ||
"codeclimate-test-reporter": "~0.3" | ||
"codeclimate-test-reporter": "~0.5", | ||
"standard": "~10" | ||
}, | ||
@@ -53,3 +53,8 @@ "keywords": [ | ||
"z85": "bin/z85-cli.js" | ||
}, | ||
"standard": { | ||
"env": [ | ||
"node" | ||
] | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# z85-cli [![Build Status](https://secure.travis-ci.org/bkimminich/z85-cli.png?branch=master)](http://travis-ci.org/bkimminich/z85-cli) [![Coverage Status](https://img.shields.io/coveralls/bkimminich/z85-cli.svg)](https://coveralls.io/r/bkimminich/z85-cli) [![Dependency Status](https://gemnasium.com/bkimminich/z85-cli.svg)](https://gemnasium.com/bkimminich/z85-cli) [![Dependency Status](https://www.versioneye.com/user/projects/561e4f5836d0ab0019000112/badge.svg?style=flat)](https://www.versioneye.com/user/projects/561e4f5836d0ab0019000112) [![Code Climate](https://codeclimate.com/github/bkimminich/z85-cli/badges/gpa.svg)](https://codeclimate.com/github/bkimminich/z85-cli) [![Test Coverage](https://codeclimate.com/github/bkimminich/z85-cli/badges/coverage.svg)](https://codeclimate.com/github/bkimminich/z85-cli/coverage) [![npm Downloads](https://img.shields.io/npm/dm/z85-cli.svg)](https://www.npmjs.com/package/z85-cli) | ||
# z85-cli [![Build Status](https://secure.travis-ci.org/bkimminich/z85-cli.png?branch=master)](http://travis-ci.org/bkimminich/z85-cli) [![Coverage Status](https://img.shields.io/coveralls/bkimminich/z85-cli.svg)](https://coveralls.io/r/bkimminich/z85-cli) [![Dependency Status](https://gemnasium.com/bkimminich/z85-cli.svg)](https://gemnasium.com/bkimminich/z85-cli) [![Dependency Status](https://www.versioneye.com/user/projects/561e4f5836d0ab0019000112/badge.svg?style=flat)](https://www.versioneye.com/user/projects/561e4f5836d0ab0019000112) [![Code Climate](https://codeclimate.com/github/bkimminich/z85-cli/badges/gpa.svg)](https://codeclimate.com/github/bkimminich/z85-cli) [![Test Coverage](https://codeclimate.com/github/bkimminich/z85-cli/badges/coverage.svg)](https://codeclimate.com/github/bkimminich/z85-cli/coverage) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) [![npm Downloads](https://img.shields.io/npm/dm/z85-cli.svg)](https://www.npmjs.com/package/z85-cli) [![Greenkeeper badge](https://badges.greenkeeper.io/bkimminich/z85-cli.svg)](https://greenkeeper.io/) | ||
@@ -29,3 +29,3 @@ Command line client for ZeroMQ Base-85 encoding | ||
## License | ||
Copyright (c) 2014-2016 Bjoern Kimminich | ||
Copyright (c) 2014-2018 Bjoern Kimminich | ||
Licensed under the MIT license. |
@@ -1,47 +0,47 @@ | ||
/*jslint node: true */ | ||
'use strict'; | ||
/* jslint node: true */ | ||
'use strict' | ||
var z85_cli = process.env.Z85_CLI_COVERAGE ? require('../lib-cov/z85-cli') : require('../lib/z85-cli'); | ||
var z85cli = process.env.Z85_CLI_COVERAGE ? require('../lib-cov/z85-cli') : require('../lib/z85-cli') | ||
exports['z85-cli'] = { | ||
'no args': function (test) { | ||
test.expect(1); | ||
test.throws(function() {z85_cli.z85cli();}, Error, 'throws an error.'); | ||
test.done(); | ||
}, | ||
'wrong mode': function (test) { | ||
test.expect(1); | ||
test.throws(function() {z85_cli.z85cli('-x', 'value');}, '', 'throws an error.'); | ||
test.done(); | ||
}, | ||
'decode non-z85 value': function (test) { | ||
test.expect(1); | ||
test.throws(function() {z85_cli.z85cli('-d', 'xxx');}, Error, 'throws an error.'); | ||
test.done(); | ||
}, | ||
'encode unencodable value': function (test) { | ||
test.expect(1); | ||
test.throws(function() {z85_cli.z85cli('-e', 'xxx');}, Error, 'throws an error.'); | ||
test.done(); | ||
}, | ||
'encode value': function (test) { | ||
test.expect(1); | ||
test.equal(z85_cli.z85cli('--encode', 'Test'), 'raQb)', 'returns encoded value.'); | ||
test.done(); | ||
}, | ||
'encode value with shorthand mode': function (test) { | ||
test.expect(1); | ||
test.equal(z85_cli.z85cli('-e', 'Test'), 'raQb)', 'returns encoded value.'); | ||
test.done(); | ||
}, | ||
'decode value': function (test) { | ||
test.expect(1); | ||
test.equal(z85_cli.z85cli('--decode', 'raQb)'), 'Test', 'returns decoded value.'); | ||
test.done(); | ||
}, | ||
'decode value with shorthand mode': function (test) { | ||
test.expect(1); | ||
test.equal(z85_cli.z85cli('-d', 'raQb)'), 'Test', 'returns decoded value.'); | ||
test.done(); | ||
} | ||
}; | ||
'no args': function (test) { | ||
test.expect(1) | ||
test.throws(function () { z85cli.z85cli() }, Error, 'throws an error.') | ||
test.done() | ||
}, | ||
'wrong mode': function (test) { | ||
test.expect(1) | ||
test.throws(function () { z85cli.z85cli('-x', 'value') }, '', 'throws an error.') | ||
test.done() | ||
}, | ||
'decode non-z85 value': function (test) { | ||
test.expect(1) | ||
test.throws(function () { z85cli.z85cli('-d', 'xxx') }, Error, 'throws an error.') | ||
test.done() | ||
}, | ||
'encode unencodable value': function (test) { | ||
test.expect(1) | ||
test.throws(function () { z85cli.z85cli('-e', 'xxx') }, Error, 'throws an error.') | ||
test.done() | ||
}, | ||
'encode value': function (test) { | ||
test.expect(1) | ||
test.equal(z85cli.z85cli('--encode', 'Test'), 'raQb)', 'returns encoded value.') | ||
test.done() | ||
}, | ||
'encode value with shorthand mode': function (test) { | ||
test.expect(1) | ||
test.equal(z85cli.z85cli('-e', 'Test'), 'raQb)', 'returns encoded value.') | ||
test.done() | ||
}, | ||
'decode value': function (test) { | ||
test.expect(1) | ||
test.equal(z85cli.z85cli('--decode', 'raQb)'), 'Test', 'returns decoded value.') | ||
test.done() | ||
}, | ||
'decode value with shorthand mode': function (test) { | ||
test.expect(1) | ||
test.equal(z85cli.z85cli('-d', 'raQb)'), 'Test', 'returns decoded value.') | ||
test.done() | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8352
105