diff options
author | Josh Goldberg <joshuakgoldberg@outlook.com> | 2018-03-08 11:30:17 +0300 |
---|---|---|
committer | Kat Marchán <kzm@sykosomatic.org> | 2018-03-09 01:20:41 +0300 |
commit | fc8761daf1e8749481457973890fa516eb96a195 (patch) | |
tree | cf5fa842264e5d83a622a52f0fe5dbaa3ea0ca77 /node_modules | |
parent | 0465009942d6423f878c1359e91972fa5990f996 (diff) |
package-lock: Added a warning for invalid pkglock JSON (#19629)
* Used json-parse-better-errors in parse-json.js
* Added json-parse-better-errors to bundleDependencies
PR-URL: https://github.com/npm/npm/pull/19629
Credit: @JoshuaKGoldberg
Reviewed-By: @zkat
Diffstat (limited to 'node_modules')
-rw-r--r-- | node_modules/json-parse-better-errors/CHANGELOG.md | 36 | ||||
-rw-r--r-- | node_modules/json-parse-better-errors/LICENSE.md | 7 | ||||
-rw-r--r-- | node_modules/json-parse-better-errors/README.md | 53 | ||||
-rw-r--r-- | node_modules/json-parse-better-errors/index.js | 32 | ||||
-rw-r--r-- | node_modules/json-parse-better-errors/package.json | 77 |
5 files changed, 205 insertions, 0 deletions
diff --git a/node_modules/json-parse-better-errors/CHANGELOG.md b/node_modules/json-parse-better-errors/CHANGELOG.md new file mode 100644 index 000000000..843a0bcb9 --- /dev/null +++ b/node_modules/json-parse-better-errors/CHANGELOG.md @@ -0,0 +1,36 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +<a name="1.0.1"></a> +## [1.0.1](https://github.com/zkat/json-parse-better-errors/compare/v1.0.0...v1.0.1) (2017-08-16) + + +### Bug Fixes + +* **license:** oops. Forgot to update license.md ([efe2958](https://github.com/zkat/json-parse-better-errors/commit/efe2958)) + + + +<a name="1.0.0"></a> +# 1.0.0 (2017-08-15) + + +### Features + +* **init:** Initial Commit ([562c977](https://github.com/zkat/json-parse-better-errors/commit/562c977)) + + +### BREAKING CHANGES + +* **init:** This is the first commit! + + + +<a name="0.1.0"></a> +# 0.1.0 (2017-08-15) + + +### Features + +* **init:** Initial Commit ([9dd1a19](https://github.com/zkat/json-parse-better-errors/commit/9dd1a19)) diff --git a/node_modules/json-parse-better-errors/LICENSE.md b/node_modules/json-parse-better-errors/LICENSE.md new file mode 100644 index 000000000..c51842cc4 --- /dev/null +++ b/node_modules/json-parse-better-errors/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2017 Kat Marchán + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/json-parse-better-errors/README.md b/node_modules/json-parse-better-errors/README.md new file mode 100644 index 000000000..667323c77 --- /dev/null +++ b/node_modules/json-parse-better-errors/README.md @@ -0,0 +1,53 @@ +# json-parse-better-errors [![npm version](https://img.shields.io/npm/v/json-parse-better-errors.svg)](https://npm.im/json-parse-better-errors) [![license](https://img.shields.io/npm/l/json-parse-better-errors.svg)](https://npm.im/json-parse-better-errors) [![Travis](https://img.shields.io/travis/zkat/json-parse-better-errors.svg)](https://travis-ci.org/zkat/json-parse-better-errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/json-parse-better-errors?svg=true)](https://ci.appveyor.com/project/zkat/json-parse-better-errors) [![Coverage Status](https://coveralls.io/repos/github/zkat/json-parse-better-errors/badge.svg?branch=latest)](https://coveralls.io/github/zkat/json-parse-better-errors?branch=latest) + +[`json-parse-better-errors`](https://github.com/zkat/json-parse-better-errors) is a Node.js library for managing +local key and content address caches. It's really fast, really good at +concurrency, and it will never give you corrupted data, even if cache files +get corrupted or manipulated. + +It was originally written to be used as [npm](https://npm.im)'s local cache, but +can just as easily be used on its own + +_Translations: [español](README.es.md)_ + +## Install + +`$ npm install --save json-parse-better-errors` + +## Table of Contents + +* [Example](#example) +* [Features](#features) +* [Contributing](#contributing) +* [API](#api) + * [`parse`](#parse) + +### Example + +```javascript +const parseJson = require('json-parse-better-errors') + +parseJson('"foo"') +parseJson('garbage') // more useful error message +``` + +### Features + +* Like JSON.parse, but the errors are better. + +### Contributing + +The json-parse-better-errors team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The [Contributor Guide](CONTRIBUTING.md) has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear. + +All participants and maintainers in this project are expected to follow [Code of Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other. + +Please refer to the [Changelog](CHANGELOG.md) for project history details, too. + +Happy hacking! + +### API + +#### <a name="parse"></a> `> parse(txt, ?reviver, ?context=20)` + +Works just like `JSON.parse`, but will include a bit more information when an +error happens. diff --git a/node_modules/json-parse-better-errors/index.js b/node_modules/json-parse-better-errors/index.js new file mode 100644 index 000000000..32c363586 --- /dev/null +++ b/node_modules/json-parse-better-errors/index.js @@ -0,0 +1,32 @@ +'use strict' + +module.exports = parseJson +function parseJson (txt, reviver, context) { + context = context || 20 + try { + return JSON.parse(txt, reviver) + } catch (e) { + const syntaxErr = e.message.match(/^Unexpected token.*position\s+(\d+)/i) + const errIdx = syntaxErr + ? +syntaxErr[1] + : e.message.match(/^Unexpected end of JSON.*/i) + ? txt.length - 1 + : null + if (errIdx != null) { + const start = errIdx <= context + ? 0 + : errIdx - context + const end = errIdx + context >= txt.length + ? txt.length + : errIdx + context + e.message += ` while parsing near '${ + start === 0 ? '' : '...' + }${txt.slice(start, end)}${ + end === txt.length ? '' : '...' + }'` + } else { + e.message += ` while parsing '${txt.slice(0, context * 2)}'` + } + throw e + } +} diff --git a/node_modules/json-parse-better-errors/package.json b/node_modules/json-parse-better-errors/package.json new file mode 100644 index 000000000..dba5f58bf --- /dev/null +++ b/node_modules/json-parse-better-errors/package.json @@ -0,0 +1,77 @@ +{ + "_from": "json-parse-better-errors", + "_id": "json-parse-better-errors@1.0.1", + "_inBundle": false, + "_integrity": "sha512-xyQpxeWWMKyJps9CuGJYeng6ssI5bpqS9ltQpdVQ90t4ql6NdnxFKh95JcRt2cun/DjMVNrdjniLPuMA69xmCw==", + "_location": "/json-parse-better-errors", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "json-parse-better-errors", + "name": "json-parse-better-errors", + "escapedName": "json-parse-better-errors", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz", + "_shasum": "50183cd1b2d25275de069e9e71b467ac9eab973a", + "_spec": "json-parse-better-errors", + "_where": "C:\\Code\\npm", + "author": { + "name": "Kat Marchán", + "email": "kzm@sykosomatic.org" + }, + "bugs": { + "url": "https://github.com/zkat/json-parse-better-errors/issues" + }, + "bundleDependencies": false, + "config": { + "nyc": { + "exclude": [ + "node_modules/**", + "test/**" + ] + } + }, + "deprecated": false, + "description": "JSON.parse with context information on error", + "devDependencies": { + "nyc": "^10.3.2", + "standard": "^9.0.2", + "standard-version": "^4.1.0", + "tap": "^10.3.3", + "weallbehave": "^1.2.0", + "weallcontribute": "^1.0.8" + }, + "files": [ + "*.js" + ], + "homepage": "https://github.com/zkat/json-parse-better-errors#readme", + "keywords": [ + "JSON", + "parser" + ], + "license": "MIT", + "main": "index.js", + "name": "json-parse-better-errors", + "repository": { + "type": "git", + "url": "git+https://github.com/zkat/json-parse-better-errors.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --coverage test/*.js", + "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", + "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" + }, + "version": "1.0.1" +} |