Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/util/JSONReadValidate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs-extra'
import JSONLint from 'json-lint'
import parseJson from 'json-parse-even-better-errors'

/**
* @param {string} filepath
Expand All @@ -24,11 +24,12 @@ export function readValidateJSONSync (filepath) {
}

function validateJSON (jsonData, filepath) {
const lint = JSONLint(jsonData)
if (!lint.error) return
let errorMessage = 'JSON parsing error: ' + lint.error + ', line: ' + lint.line + ', character: ' + lint.character
if (filepath) {
errorMessage += ', file: \'' + filepath + '\''
try {
parseJson(jsonData)
} catch (err) {
const msg = filepath
? `${err.message} in file '${filepath}'`
: err.message
throw new Error(msg)
}
throw new Error(errorMessage)
}
38 changes: 23 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"fs-extra": "^10.0.0",
"globs": "^0.1.4",
"inquirer": "^7.3.3",
"json-lint": "^0.1.0",
"json-parse-even-better-errors": "^5.0.0",
"lodash-es": "^4.17.21",
"node-fetch": "^3.2.10",
"parse-github-url": "^1.0.2",
Expand All @@ -30,17 +30,17 @@
"adapt": "./bin/adapt.js"
},
"devDependencies": {
"eslint": "^7.31.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.5",
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"conventional-changelog-eslint": "^3.0.9",
"eslint": "^7.31.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"semantic-release": "^19.0.3"
},
"release": {
Expand Down