Comparing version 0.3.0 to 0.5.0
#!/usr/bin/env node | ||
/* jslint node: true */ | ||
'use strict' | ||
const lib = require('../lib/z85-cli') | ||
var lib = require('../lib/z85-cli') | ||
const userArgs = process.argv.slice(2) | ||
const mode = userArgs[0] | ||
const value = userArgs[1] | ||
var userArgs = process.argv.slice(2) | ||
var mode = userArgs[0] | ||
var value = userArgs[1] | ||
try { | ||
@@ -12,0 +10,0 @@ console.log(lib.z85cli(mode, value)) |
@@ -5,3 +5,3 @@ /* jslint node: true */ | ||
module.exports = function (grunt) { | ||
// Project configuration. | ||
// Project configuration. | ||
grunt.initConfig({ | ||
@@ -13,8 +13,8 @@ nodeunit: { | ||
// These plugins provide necessary tasks. | ||
// These plugins provide necessary tasks. | ||
grunt.loadNpmTasks('grunt-contrib-nodeunit') | ||
// Default task. | ||
// Default task. | ||
grunt.registerTask('test', ['nodeunit']) | ||
grunt.registerTask('default', ['test']) | ||
} |
/* jslint node: true */ | ||
'use strict' | ||
const 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() | ||
} | ||
} else { | ||
const z85cli = (mode, value) => { | ||
if (!mode || !value) { | ||
throw logDocumentation() | ||
} | ||
if (isEncode(mode)) { | ||
return encode(value) | ||
} else if (isDecode(mode)) { | ||
return decode(value) | ||
} | ||
throw logDocumentation() | ||
} | ||
function isEncode (mode) { | ||
return mode === '--encode' || mode === '-e' | ||
} | ||
function isDecode (mode) { | ||
return mode === '--decode' || mode === '-d' | ||
} | ||
function encode (value) { | ||
const encoded = z85.encode(value) | ||
if (encoded) { | ||
return encoded | ||
} | ||
throw encodingError() | ||
} | ||
function decode (value) { | ||
let decoded = z85.decode(value) | ||
if (decoded) { | ||
decoded = decoded.toString() | ||
return decoded | ||
} | ||
throw decodingError() | ||
} | ||
function logDocumentation () { | ||
@@ -37,2 +47,10 @@ return new Error('\nRun options:\n' + | ||
function encodingError () { | ||
return new Error('Input cannot be z85 encoded. See http://rfc.zeromq.org/spec:32') | ||
} | ||
function decodingError () { | ||
return new Error('Input not recognized as z85 encoded. See http://rfc.zeromq.org/spec:32') | ||
} | ||
exports.z85cli = z85cli |
{ | ||
"name": "z85-cli", | ||
"description": "Command line client for ZeroMQ Base-85 encoding", | ||
"version": "0.3.0", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/bkimminich/z85-cli", | ||
@@ -19,3 +19,3 @@ "author": { | ||
"engines": { | ||
"node": ">=0.10" | ||
"node": ">=8" | ||
}, | ||
@@ -31,9 +31,9 @@ "scripts": { | ||
"devDependencies": { | ||
"codeclimate-test-reporter": "~0.5", | ||
"coveralls": "^3.0.14", | ||
"grunt": "^1.0.4", | ||
"grunt-contrib-nodeunit": "~2.0", | ||
"jscoverage": "~0.6", | ||
"nodeunit": "~0.11", | ||
"jscoverage": "~0.6", | ||
"coveralls": "~3.0", | ||
"grunt": "~1.0", | ||
"grunt-contrib-nodeunit": "~1.0", | ||
"codeclimate-test-reporter": "~0.5", | ||
"standard": "~10" | ||
"standard": "~12" | ||
}, | ||
@@ -50,3 +50,3 @@ "keywords": [ | ||
], | ||
"preferGlobal": "true", | ||
"preferGlobal": true, | ||
"bin": { | ||
@@ -53,0 +53,0 @@ "z85": "bin/z85-cli.js" |
@@ -1,6 +0,15 @@ | ||
# 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/) | ||
# z85-cli [![npm Downloads](https://img.shields.io/npm/dm/z85-cli.svg)](https://www.npmjs.com/package/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) | ||
[![Code Climate](https://codeclimate.com/github/bkimminich/z85-cli/badges/gpa.svg)](https://codeclimate.com/github/bkimminich/z85-cli) | ||
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/bkimminich/z85-cli.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bkimminich/z85-cli/context:javascript) | ||
[![Total alerts](https://img.shields.io/lgtm/alerts/g/bkimminich/z85-cli.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bkimminich/z85-cli/alerts/) | ||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/bkimminich/z85-cli.svg)](https://greenkeeper.io/) | ||
Command line client for ZeroMQ Base-85 encoding | ||
## Getting Started | ||
## Getting Started ![node](https://img.shields.io/node/v/z85-cli.svg) | ||
Install the module with: | ||
@@ -29,3 +38,3 @@ | ||
## License | ||
Copyright (c) 2014-2018 Bjoern Kimminich | ||
Copyright (c) 2014-2019 Bjoern Kimminich | ||
Licensed under the MIT license. |
/* jslint node: true */ | ||
'use strict' | ||
const z85cli = 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 () { z85cli.z85cli() }, Error, 'throws an error.') | ||
test.throws(() => { z85cli.z85cli() }, Error, 'throws an error.') | ||
test.done() | ||
@@ -14,3 +12,3 @@ }, | ||
test.expect(1) | ||
test.throws(function () { z85cli.z85cli('-x', 'value') }, '', 'throws an error.') | ||
test.throws(() => { z85cli.z85cli('-x', 'value') }, '', 'throws an error.') | ||
test.done() | ||
@@ -20,3 +18,3 @@ }, | ||
test.expect(1) | ||
test.throws(function () { z85cli.z85cli('-d', 'xxx') }, Error, 'throws an error.') | ||
test.throws(() => { z85cli.z85cli('-d', 'xxx') }, Error, 'throws an error.') | ||
test.done() | ||
@@ -26,3 +24,3 @@ }, | ||
test.expect(1) | ||
test.throws(function () { z85cli.z85cli('-e', 'xxx') }, Error, 'throws an error.') | ||
test.throws(() => { z85cli.z85cli('-e', 'xxx') }, Error, 'throws an error.') | ||
test.done() | ||
@@ -29,0 +27,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9426
12
116
40