From e07df125ad304e1aa216cfadfee7d9725e052aaf Mon Sep 17 00:00:00 2001 From: Adam Voss Date: Fri, 4 Aug 2017 13:00:07 -0500 Subject: [PATCH 1/2] Update any-json dependency --- README.md | 4 ++-- commands/help.js | 10 +++++----- commands/util.js | 4 +++- package.json | 9 ++++++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4c10bc1..bbe5859 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Polyglottal JSON Schema Validator (Polyglottal Ajv) -Command line interface for [ajv](https://github.com/epoberezkin/ajv) that utilizes [any-json](https://github.com/laktak/any-json/) to provide validation against many data formats. `pajv` can validate: **[CSON](https://github.com/bevry/cson), [Hjson](http://hjson.org/), [JSON](http://json.org/), [JSON5](http://json5.org/), and [YAML](http://yaml.org/)** files using JSON Schema. pajv is a fork of [ajv-cli](https://github.com/jessedc/ajv-cli). +Command line interface for [ajv](https://github.com/epoberezkin/ajv) that utilizes [any-json](https://github.com/laktak/any-json/) to provide validation against many data formats. `pajv` can validate: **[CSON](https://github.com/bevry/cson), [Hjson](http://hjson.org/), [JSON](http://json.org/), [JSON5](http://json5.org/), [TOML](https://github.com/toml-lang/toml), and [YAML](http://yaml.org/)** files using JSON Schema. pajv is a fork of [ajv-cli](https://github.com/jessedc/ajv-cli). [![Build Status](https://travis-ci.org/json-schema-everywhere/pajv.svg?branch=master)](https://travis-ci.org/json-schema-everywhere/pajv) [![npm version](https://badge.fury.io/js/pajv.svg)](https://www.npmjs.com/package/pajv) @@ -43,7 +43,7 @@ pajv validate -s test/schema.json -d test/valid_data.json pajv -s test/schema.json -d test/valid_data.json ``` -You can omit `validate` command name and `.json` from the [input file names](https://nodejs.org/api/modules.html#modules_file_modules). +You can omit `validate` command name. #### Parameters diff --git a/commands/help.js b/commands/help.js index 9deacc2..2e40850 100644 --- a/commands/help.js +++ b/commands/help.js @@ -89,8 +89,8 @@ options:\n\ function _helpValidate() { console.log('\ Validate data file(s) against schema\n\ - ajv [validate] -s schema_file -d data_file\n\ - ajv [validate] -s schema_file -d "data*.ext"\n'); + pajv [validate] -s schema_file -d data_file\n\ + pajv [validate] -s schema_file -d "data*.ext"\n'); } function helpTest() { @@ -123,9 +123,9 @@ options:\n\ function _helpTest() { console.log('\ Test data validation result\n\ - ajv test -s schema_file -d data_file --valid\n\ - ajv test -s schema_file -d data_file --invalid\n\ - ajv test -s schema_file -d "data*.ext" --valid \n'); + pajv test -s schema_file -d data_file --valid\n\ + pajv test -s schema_file -d data_file --invalid\n\ + pajv test -s schema_file -d "data*.ext" --valid \n'); } diff --git a/commands/util.js b/commands/util.js index 60f0518..fb72d3e 100644 --- a/commands/util.js +++ b/commands/util.js @@ -4,6 +4,7 @@ var anyjson = require('any-json'); var glob = require('glob'); var path = require('path'); var fs = require('fs'); +var wait = require('deasync-promise'); module.exports = { @@ -35,7 +36,8 @@ function openFile(filename, suffix){ var file = path.resolve(process.cwd(), filename); try { var contents = fs.readFileSync(file).toString(); - return anyjson.convert(contents, path.extname(filename)); + var format = path.extname(filename).substr(1).toLowerCase(); + return wait(anyjson.decode(contents, format)); } catch(err) { console.error('error: ' + err.message.replace(' module', ' ' + suffix)); process.exit(2); diff --git a/package.json b/package.json index 46ee99e..f979d98 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "pajv", "displayName": "Polyglottal JSON Schema Validator", - "version": "1.0.1", - "description": " A command line JSON Schema validator that supports many file formats. Fork of jessedc/ajv-cli.", + "version": "1.1.0", + "description": "A command line JSON Schema validator that supports many file formats. Fork of jessedc/ajv-cli.", "scripts": { "eslint": "eslint index.js commands/*.js test/*.js test/**/*.js", "test-spec": "mocha test/*.spec.js -R spec", @@ -37,6 +37,7 @@ "hjson", "ini", "json5", + "toml", "xml", "yaml" ], @@ -54,7 +55,9 @@ }, "dependencies": { "ajv": "^5.0.0", - "any-json": "^2.2.0", + "any-json": "^3.0.0", + "deasync": "^0.1.10", + "deasync-promise": "^1.0.1", "fast-json-patch": "^0.5.6", "glob": "^7.0.3", "minimist": "^1.2.0", From 8d47a2422dff37a2ea22392d5c3cc6f75ce3ec6b Mon Sep 17 00:00:00 2001 From: Adam Voss Date: Fri, 4 Aug 2017 13:10:30 -0500 Subject: [PATCH 2/2] Remove support for Node.js v4 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d21565c..49409dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: node_js before_script: - npm install -g codeclimate-test-reporter node_js: - - '4' - '6' - '7' after_script: @@ -21,4 +20,4 @@ deploy: GZPWd1vS6FdbLG3usxZnImymG+AS0WdOY5NYz4DNW1UYhmJzOIilSbF0PGqjL0OzbtpeFvRPVEuqvu3LYI623YwsTDg4faycRXMo0OyVjS5vBq4CFF/JBTfkauxUZNq6cpMSg6f55sNshGuS4gGpnKBKkK6Bx8IkQRnEFJ44yfLWmyjPWmaGVEo5aXe6ZStdgLjvXNqL+uIcD57ssn8/nPsezZEAC+S3Kn9fYTqgyt21AaQQ7Hy/QW8JsYNikUlV/3xvueQftd8ILupm8PQ0SYhAgR35aIUbhDk8rEHmezFXGKOovNxDmqnZCAoZyP8WOn81Ey0Z14INZCz/qPBbPgjhhs7Q4O5Pq7SbwCEjqFUkQQ97yvUog28YwsRajl21tC20DXLxknWN06nKtu5EHnmGL9FGwUQt9mVumuJXF2NGHv8KS0EGMGMn9LSdCS89CtMrR/MhkRxCnjikHWxLIxIsDlklyQLY+6Lxc0cXAcLOULTDlOJFLlRCUU8FNxiHJkocFbw+oeVrn4ZzwAhdgAPmWGA+/fxx7cnxs4DSHaEZ3CnAC6rL5vEsKbA0IOjWDER0KbcVTU2OKm6+vZ1W3HP2fl4xbdENYTl78kk2ZXdTi4JtGoBeYX7nNuy+iDcYpLG4Jltna3L3UfvOblTSrXu8dEeTBZOYhryN6eQUi50= email: vossad01@gmail.com 'on': - tags: true \ No newline at end of file + tags: true