diff options
author | Rebecca Turner <me@re-becca.org> | 2017-06-27 01:18:13 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2017-06-27 02:14:33 +0300 |
commit | 722e65a4232ca00666496c5baa8db664f63f775a (patch) | |
tree | 67efcd2fc745765859256ef14b523b17be1a6fc0 /node_modules/read-package-json | |
parent | d04a23de21dd9991b32029d839b71e10e07b400d (diff) |
read-package-json@2.0.7
Diffstat (limited to 'node_modules/read-package-json')
22 files changed, 53 insertions, 377 deletions
diff --git a/node_modules/read-package-json/.npmignore b/node_modules/read-package-json/.npmignore deleted file mode 100644 index 8c23deeb3..000000000 --- a/node_modules/read-package-json/.npmignore +++ /dev/null @@ -1,13 +0,0 @@ -*.swp -.*.swp - -.DS_Store -*~ -.project -.settings -npm-debug.log -coverage.html -.idea -lib-cov - -node_modules diff --git a/node_modules/read-package-json/.travis.yml b/node_modules/read-package-json/.travis.yml deleted file mode 100644 index f84676a90..000000000 --- a/node_modules/read-package-json/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: node_js -node_js: - - '0.8' - - '0.10' - - '0.12' - - 'iojs' -sudo: false -before_install: - - npm install -g npm@latest diff --git a/node_modules/read-package-json/package.json b/node_modules/read-package-json/package.json index bde37bd14..dd78f7c08 100644 --- a/node_modules/read-package-json/package.json +++ b/node_modules/read-package-json/package.json @@ -1,36 +1,36 @@ { - "_from": "read-package-json@~2.0.5", - "_id": "read-package-json@2.0.5", - "_integrity": "sha1-+Tpk5kFSnfaKCMZN5GOJ6KP4iEU=", + "_from": "read-package-json@2.0.7", + "_id": "read-package-json@2.0.7", + "_inBundle": false, + "_integrity": "sha512-0rbvaY14ox+gjOpyaOB28iIbqCKephWiKv0HBOIExYCiuKm7PXLUk3gFN0xl/ZnRYC7Nd2D96KtO3kFtve9XFQ==", "_location": "/read-package-json", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "read-package-json@~2.0.5", + "raw": "read-package-json@2.0.7", "name": "read-package-json", "escapedName": "read-package-json", - "rawSpec": "~2.0.5", + "rawSpec": "2.0.7", "saveSpec": null, - "fetchSpec": "~2.0.5" + "fetchSpec": "2.0.7" }, "_requiredBy": [ + "#USER", "/", "/init-package-json", "/read-installed", "/read-package-tree" ], - "_resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-2.0.5.tgz", - "_shasum": "f93a64e641529df68a08c64de46389e8a3f88845", - "_shrinkwrap": null, - "_spec": "read-package-json@~2.0.5", - "_where": "/Users/zkat/Documents/code/npm", + "_resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-2.0.7.tgz", + "_shasum": "c79ed6059753dafdd21b150f864735b274ac2c2d", + "_spec": "read-package-json@2.0.7", + "_where": "/Users/rebecca/code/npm", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", "url": "http://blog.izs.me/" }, - "bin": null, "bugs": { "url": "https://github.com/npm/read-package-json/issues" }, @@ -47,6 +47,9 @@ "standard": "^9.0.1", "tap": "^10.3.0" }, + "files": [ + "read-json.js" + ], "homepage": "https://github.com/npm/read-package-json#readme", "license": "ISC", "main": "read-json.js", @@ -54,7 +57,6 @@ "optionalDependencies": { "graceful-fs": "^4.1.2" }, - "peerDependencies": {}, "repository": { "type": "git", "url": "git+https://github.com/npm/read-package-json.git" @@ -62,5 +64,5 @@ "scripts": { "test": "standard && tap -J test/*.js" }, - "version": "2.0.5" + "version": "2.0.7" } diff --git a/node_modules/read-package-json/read-json.js b/node_modules/read-package-json/read-json.js index 26986b261..70ddb09b3 100644 --- a/node_modules/read-package-json/read-json.js +++ b/node_modules/read-package-json/read-json.js @@ -10,6 +10,7 @@ var path = require('path') var glob = require('glob') var normalizeData = require('normalize-package-data') var safeJSON = require('json-parse-helpfulerror') +var util = require('util') module.exports = readJson @@ -26,6 +27,7 @@ readJson.extraSet = [ ] var typoWarned = {} +var cache = {} function readJson (file, log_, strict_, cb_) { var log, strict, cb @@ -72,14 +74,27 @@ function parseJson (file, er, d, log, strict, cb) { } if (er) return cb(er) + if (cache[d]) return cb(null, cache[d]) + + var data + try { - d = safeJSON.parse(stripBOM(d)) + data = safeJSON.parse(stripBOM(d)) } catch (er) { - d = parseIndex(d) - if (!d) return cb(parseError(er, file)) + data = parseIndex(d) + if (!data) return cb(parseError(er, file)) } - extras(file, d, log, strict, cb) + extrasCached(file, d, data, log, strict, cb) +} + +function extrasCached (file, d, data, log, strict, cb) { + extras(file, data, log, strict, (err, data) => { + if (!err) { + cache[d] = data + } + cb(err, data) + }) } function indexjs (file, er, log, strict, cb) { @@ -89,10 +104,12 @@ function indexjs (file, er, log, strict, cb) { fs.readFile(index, 'utf8', function (er2, d) { if (er2) return cb(er) - d = parseIndex(d) - if (!d) return cb(er) + if (cache[d]) return cb(null, cache[d]) + + var data = parseIndex(d) + if (!data) return cb(er) - extras(file, d, log, strict, cb) + extrasCached(file, d, data, log, strict, cb) }) } @@ -150,6 +167,7 @@ function gypfile (file, data, cb) { glob('*.gyp', { cwd: dir }, function (er, files) { if (er) return cb(er) + if (data.gypfile === false) return cb(null, data) gypfile_(file, data, files, cb) }) } @@ -332,8 +350,17 @@ function checkBinReferences_ (file, data, warn, cb) { keys.forEach(function (key) { var dirName = path.dirname(file) var relName = data.bin[key] - var binPath = path.resolve(dirName, relName) - fs.exists(binPath, handleExists.bind(null, relName)) + try { + var binPath = path.resolve(dirName, relName) + fs.exists(binPath, handleExists.bind(null, relName)) + } catch (error) { + if (error.message === 'Arguments to path.resolve must be strings' || error.message.indexOf('Path must be a string') === 0) { + warn('Bin filename for ' + key + ' is not a string: ' + util.inspect(relName)) + handleExists(relName, true) + } else { + cb(error) + } + } }) } diff --git a/node_modules/read-package-json/test/basic.js b/node_modules/read-package-json/test/basic.js deleted file mode 100644 index 5996c8e4e..000000000 --- a/node_modules/read-package-json/test/basic.js +++ /dev/null @@ -1,46 +0,0 @@ -var fs = require('fs') -var path = require('path') - -var tap = require('tap') - -var readJson = require('../') - -var readme = fs.readFileSync(path.resolve(__dirname, '../README.md'), 'utf8') -var pkg = require('../package.json') -var isGit -try { - fs.readFileSync(path.resolve(__dirname, '../.git/HEAD')) - isGit = true -} catch (e) { - isGit = false -} - -tap.test('basic test', function (t) { - var p = path.resolve(__dirname, '../package.json') - readJson(p, function (er, data) { - if (er) throw er - basic_(t, data) - }) -}) - -function basic_ (t, data) { - t.ok(data) - t.equal(data.version, pkg.version) - t.equal(data._id, data.name + '@' + data.version) - t.equal(data.name, pkg.name) - t.type(data.author, 'object') - t.equal(data.readme, readme) - t.deepEqual(data.scripts, pkg.scripts) - t.equal(data.main, pkg.main) - t.equal(data.readmeFilename, 'README.md') - - if (isGit) t.similar(data.gitHead, /^[a-f0-9]{40}$/) - - // optional deps are folded in. - t.deepEqual(data.optionalDependencies, pkg.optionalDependencies) - t.has(data.dependencies, pkg.optionalDependencies) - t.has(data.dependencies, pkg.dependencies) - - t.deepEqual(data.devDependencies, pkg.devDependencies) - t.end() -} diff --git a/node_modules/read-package-json/test/bin.js b/node_modules/read-package-json/test/bin.js deleted file mode 100644 index 3e0e0e9be..000000000 --- a/node_modules/read-package-json/test/bin.js +++ /dev/null @@ -1,43 +0,0 @@ -var path = require('path') - -var tap = require('tap') - -var readJson = require('../') - -var createWarningCollector = function () { - var warn = function (msg) { - warn.warnings.push(arguments) - } - warn.warnings = [] - return warn -} - -tap.test('Bin test', function (t) { - var p = path.resolve(__dirname, 'fixtures/bin.json') - var warn = createWarningCollector() - readJson(p, warn, function (er, data) { - t.equals(warn.warnings.length, 0) - t.deepEqual(data.bin, {'bin-test': './bin/echo'}) - t.end() - }) -}) - -tap.test('Bad bin test', function (t) { - var p = path.resolve(__dirname, 'fixtures/badbin.json') - var warn = createWarningCollector() - readJson(p, warn, function (er, data) { - t.equals(warn.warnings.length, 1) - t.equals(warn.warnings[0][2], 'No bin file found at ./bin/typo') - t.end() - }) -}) - -tap.test('Empty bin test', function (t) { - var p = path.resolve(__dirname, 'fixtures/emptybin.json') - var warn = createWarningCollector() - readJson(p, warn, function (er, data) { - t.equals(warn.warnings.length, 0) - t.same(data.bin, {}, 'no mapping to bin because object was empty') - t.end() - }) -}) diff --git a/node_modules/read-package-json/test/bom.js b/node_modules/read-package-json/test/bom.js deleted file mode 100644 index 372a4f4ab..000000000 --- a/node_modules/read-package-json/test/bom.js +++ /dev/null @@ -1,16 +0,0 @@ -var tap = require('tap') -var readJson = require('../') -var path = require('path') - -tap.test('BOM test', function (t) { - var p = path.resolve(__dirname, 'fixtures/bom.json') - readJson(p, function (er, data) { - if (er) throw er - p = path.resolve(__dirname, 'fixtures/nobom.json') - readJson(p, function (er, data2) { - if (er) throw er - t.deepEqual(data, data2) - t.end() - }) - }) -}) diff --git a/node_modules/read-package-json/test/fixtures/badbin.json b/node_modules/read-package-json/test/fixtures/badbin.json deleted file mode 100644 index 3eb58d9c1..000000000 --- a/node_modules/read-package-json/test/fixtures/badbin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "badbin-test", - "description": "my desc", - "repository": { - "type": "git", - "url": "git://github.com/npm/read-package-json.git" - }, - "version": "0.0.1", - "readme": "hello world", - "bin": "./bin/typo", - "license": "ISC" -} diff --git a/node_modules/read-package-json/test/fixtures/bin.json b/node_modules/read-package-json/test/fixtures/bin.json deleted file mode 100644 index 70a26eec7..000000000 --- a/node_modules/read-package-json/test/fixtures/bin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "bin-test", - "description": "my desc", - "repository": { - "type": "git", - "url": "git://github.com/npm/read-package-json.git" - }, - "version": "0.0.1", - "readme": "hello world", - "bin": "./bin/echo", - "license": "ISC" -} diff --git a/node_modules/read-package-json/test/fixtures/bin/echo b/node_modules/read-package-json/test/fixtures/bin/echo deleted file mode 100644 index aaed87850..000000000 --- a/node_modules/read-package-json/test/fixtures/bin/echo +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "Hello world"
\ No newline at end of file diff --git a/node_modules/read-package-json/test/fixtures/bom.json b/node_modules/read-package-json/test/fixtures/bom.json deleted file mode 100644 index 1beddca2c..000000000 --- a/node_modules/read-package-json/test/fixtures/bom.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "this", - "description": "file", - "author": "has <filename>", - "version" : "0.0.1" -}
\ No newline at end of file diff --git a/node_modules/read-package-json/test/fixtures/emptybin.json b/node_modules/read-package-json/test/fixtures/emptybin.json deleted file mode 100644 index 4fbf40075..000000000 --- a/node_modules/read-package-json/test/fixtures/emptybin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "emptybin-test", - "description": "my desc", - "repository": { - "type": "git", - "url": "git://github.com/npm/read-package-json.git" - }, - "version": "0.0.1", - "readme": "hello world", - "bin": {}, - "license": "ISC" -} diff --git a/node_modules/read-package-json/test/fixtures/erroneous.json b/node_modules/read-package-json/test/fixtures/erroneous.json deleted file mode 100644 index 212e37ec8..000000000 --- a/node_modules/read-package-json/test/fixtures/erroneous.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - 'wrong': 'kind', - 'of': 'quotes' -} diff --git a/node_modules/read-package-json/test/fixtures/nobom.json b/node_modules/read-package-json/test/fixtures/nobom.json deleted file mode 100644 index f0ea8978f..000000000 --- a/node_modules/read-package-json/test/fixtures/nobom.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "this", - "description": "file", - "author": "has <filename>", - "version" : "0.0.1" -}
\ No newline at end of file diff --git a/node_modules/read-package-json/test/fixtures/not-json.css b/node_modules/read-package-json/test/fixtures/not-json.css deleted file mode 100644 index 1a1b5672d..000000000 --- a/node_modules/read-package-json/test/fixtures/not-json.css +++ /dev/null @@ -1,37 +0,0 @@ -body { - height: super tall -} - -/**package -{ - "name": "read-package-json", - "version": "0.1.1", - "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", - "description": "The thing npm uses to read package.json files with semantics and defaults and validation", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/read-package-json.git" - }, - "main": "read-json.js", - "scripts": { - "test": "./node_modules/.bin/tap test/*.js" - }, - "dependencies": { - "glob": "~3.1.9", - "lru-cache": "~1.1.0", - "semver": "~1.0.14", - "slide": "~1.1.3" - }, - "devDependencies": { - "tap": "~0.2.5" - }, - "optionalDependencies": { - "npmlog": "0", - "graceful-fs": "~1.1.8" - } -} -**/ - -html { - width: wow so wide -} diff --git a/node_modules/read-package-json/test/fixtures/readmes/README b/node_modules/read-package-json/test/fixtures/readmes/README deleted file mode 100644 index 257cc5642..000000000 --- a/node_modules/read-package-json/test/fixtures/readmes/README +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/node_modules/read-package-json/test/fixtures/readmes/README.md b/node_modules/read-package-json/test/fixtures/readmes/README.md deleted file mode 100644 index e444c2f0f..000000000 --- a/node_modules/read-package-json/test/fixtures/readmes/README.md +++ /dev/null @@ -1 +0,0 @@ -*markdown* diff --git a/node_modules/read-package-json/test/fixtures/readmes/package.json b/node_modules/read-package-json/test/fixtures/readmes/package.json deleted file mode 100644 index b0c1a318a..000000000 --- a/node_modules/read-package-json/test/fixtures/readmes/package.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"readmes", "version":"99.999.999999999"} diff --git a/node_modules/read-package-json/test/fixtures/readmes/readmexxx.yz b/node_modules/read-package-json/test/fixtures/readmes/readmexxx.yz deleted file mode 100644 index 662da9128..000000000 --- a/node_modules/read-package-json/test/fixtures/readmes/readmexxx.yz +++ /dev/null @@ -1 +0,0 @@ -extra noise diff --git a/node_modules/read-package-json/test/helpful.js b/node_modules/read-package-json/test/helpful.js deleted file mode 100644 index 84f531360..000000000 --- a/node_modules/read-package-json/test/helpful.js +++ /dev/null @@ -1,20 +0,0 @@ -var tap = require('tap') -var readJson = require('../') -var path = require('path') -var p = path.resolve(__dirname, 'fixtures/erroneous.json') - -tap.test('erroneous package data', function (t) { - readJson(p, function (er, data) { - t.ok(er instanceof Error) - t.ok(er.message.match(/Unexpected token '\\''/)) - t.end() - }) -}) - -tap.test('ENOTDIR for non-directory packages', function (t) { - readJson(path.resolve(__filename, 'package.json'), function (er, data) { - t.ok(er) - t.equal(er.code, 'ENOTDIR') - t.end() - }) -}) diff --git a/node_modules/read-package-json/test/non-json.js b/node_modules/read-package-json/test/non-json.js deleted file mode 100644 index 85186320a..000000000 --- a/node_modules/read-package-json/test/non-json.js +++ /dev/null @@ -1,83 +0,0 @@ -var path = require('path') - -var tap = require('tap') - -var readJson = require('../') - -var expect = { - name: 'read-package-json', - version: '0.1.1', - author: { - name: 'Isaac Z. Schlueter', - email: 'i@izs.me', - url: 'http://blog.izs.me/' - }, - description: 'The thing npm uses to read package.json files with semantics and defaults and validation', - repository: { - type: 'git', - url: 'git://github.com/isaacs/read-package-json.git' - }, - bugs: { - url: 'https://github.com/isaacs/read-package-json/issues' - }, - main: 'read-json.js', - scripts: { test: 'tap test/*.js' }, - dependencies: { - glob: '~3.1.9', - 'lru-cache': '~1.1.0', - semver: '~1.0.14', - slide: '~1.1.3', - npmlog: '0', - 'graceful-fs': '~1.1.8' - }, - devDependencies: { tap: '~0.2.5' }, - homepage: 'https://github.com/isaacs/read-package-json#readme', - optionalDependencies: { npmlog: '0', 'graceful-fs': '~1.1.8' }, - _id: 'read-package-json@0.1.1', - readme: 'ERROR: No README data found!' -} - -tap.test('from css', function (t) { - var c = path.join(__dirname, 'fixtures', 'not-json.css') - readJson(c, function (er, d) { - t.same(d, expect) - t.end() - }) -}) - -tap.test('from js', function (t) { - readJson(__filename, function (er, d) { - t.same(d, expect) - t.end() - }) -}) - -/**package -{ - "name": "read-package-json", - "version": "0.1.1", - "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", - "description": "The thing npm uses to read package.json files with semantics and defaults and validation", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/read-package-json.git" - }, - "main": "read-json.js", - "scripts": { - "test": "tap test/*.js" - }, - "dependencies": { - "glob": "~3.1.9", - "lru-cache": "~1.1.0", - "semver": "~1.0.14", - "slide": "~1.1.3" - }, - "devDependencies": { - "tap": "~0.2.5" - }, - "optionalDependencies": { - "npmlog": "0", - "graceful-fs": "~1.1.8" - } -} -**/ diff --git a/node_modules/read-package-json/test/readmes.js b/node_modules/read-package-json/test/readmes.js deleted file mode 100644 index bd8917721..000000000 --- a/node_modules/read-package-json/test/readmes.js +++ /dev/null @@ -1,27 +0,0 @@ -var path = require('path') - -var tap = require('tap') -var p = path.resolve(__dirname, 'fixtures/readmes/package.json') - -var readJson = require('../') - -var expect = { - 'name': 'readmes', - 'version': '99.999.999999999', - 'readme': '*markdown*\n', - 'readmeFilename': 'README.md', - 'description': '*markdown*', - '_id': 'readmes@99.999.999999999' -} - -tap.test('readme test', function (t) { - readJson(p, function (er, data) { - t.ifError(er, 'read README without error') - test(t, data) - }) -}) - -function test (t, data) { - t.deepEqual(data, expect) - t.end() -} |