...
 
Commits (9)
......@@ -10,4 +10,6 @@ coverage.html
.idea
lib-cov
.nyc_output
node_modules
language: node_js
node_js:
- '6'
- '4'
- '8'
sudo: false
before_install:
- npm install -g npm@latest
# 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="2.0.13"></a>
## [2.0.13](https://github.com/npm/read-package-json/compare/v2.0.12...v2.0.13) (2018-03-08)
### Bug Fixes
* **git:** support git packed refs --all mode ([#77](https://github.com/npm/read-package-json/issues/77)) ([1869940](https://github.com/npm/read-package-json/commit/1869940))
......@@ -67,12 +67,6 @@ independent.
Mix and match!
## readJson.cache
The `lru-cache` object that readJson uses to not read the same file over
and over again. See
[lru-cache](https://github.com/isaacs/node-lru-cache) for details.
## Other Relevant Files Besides `package.json`
Some other files have an effect on the resulting data object, in the
......@@ -105,15 +99,6 @@ If a bindings.gyp file exists, and there is not already a
`scripts.install` field, then the `scripts.install` field will be set to
`node-gyp rebuild`.
### `wscript`
If a wscript file exists, and there is not already a `scripts.install`
field, then the `scripts.install` field will be set to `node-waf clean ;
node-waf configure build`.
Note that the `bindings.gyp` file supercedes this, since node-waf has
been deprecated in favor of node-gyp.
### `index.js`
If the json file does not exist, but there is a `index.js` file
......
node-read-package-json (2.0.13-1) unstable; urgency=medium
* Team upload
* New upstream version 2.0.13
* Use salsa.debian.org in Vcs-* fields
* Bump debhelper compatibility level to 11
* Change section to javascript and priority to optional
* Bump Standards-Version to 4.2.1 (no changes needed)
* Tighten dependency versions
* Enable tests and autopkgtest
-- Pirate Praveen <praveen@debian.org> Sat, 15 Sep 2018 16:18:21 +0530
node-read-package-json (1.2.4-1) unstable; urgency=medium
* Imported Upstream version 1.2.4
......
Source: node-read-package-json
Section: web
Priority: extra
Section: javascript
Priority: optional
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Uploaders: Jérémy Lal <kapouer@melix.org>
Build-Depends:
debhelper (>= 8.0.0)
, dh-buildinfo
Standards-Version: 3.9.5
Build-Depends: debhelper (>= 11~)
, nodejs
, node-tap <!nocheck>
, node-glob (>= 7.1.1~) <!nocheck>
, node-json-parse-better-errors (>= 1.0.1~) <!nocheck>
, node-normalize-package-data (>= 2.0~) <!nocheck>
, node-slash (>= 1.0~) <!nocheck>
Standards-Version: 4.2.1
Homepage: https://github.com/isaacs/read-package-json
Vcs-Git: git://anonscm.debian.org/pkg-javascript/node-read-package-json.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-javascript/node-read-package-json.git
Vcs-Git: https://salsa.debian.org/js-team/node-read-package-json.git
Vcs-Browser: https://salsa.debian.org/js-team/node-read-package-json
Package: node-read-package-json
Architecture: all
Depends:
${misc:Depends}
, nodejs
, node-glob (>= 3.2.1)
, node-lru-cache (>= 2)
, node-normalize-package-data
, node-glob (>= 7.1.1~)
, node-json-parse-better-errors (>= 1.0.1~)
, node-normalize-package-data (>= 2.0~)
, node-slash (>= 1.0~)
Recommends:
node-graceful-fs (>= 2)
node-graceful-fs (>= 4.1.2~)
Description: Read package.json for npm module for Node.js
This module reads package.json files with semantics, defaults, and
validation for npm consumption.
......
......@@ -6,3 +6,8 @@
%:
dh $@
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_PROFILES)))
tap test/*.js
endif
Tests: require
Depends: node-read-package-json
Test-Command: tap test/*.js
Depends: @, node-tap
#!/bin/sh
set -e
nodejs -e "require('read-package-json');"
This diff is collapsed.
{
"name": "read-package-json",
"version": "1.2.4",
"version": "2.0.13",
"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"
"url": "https://github.com/npm/read-package-json.git"
},
"main": "read-json.js",
"scripts": {
"test": "tap test/*.js"
"prerelease": "npm t",
"postrelease": "npm publish && git push --follow-tags",
"pretest": "standard",
"release": "standard-version -s",
"test": "tap --nyc-arg=--all --coverage test/*.js"
},
"dependencies": {
"glob": "^4.0.2",
"lru-cache": "2",
"normalize-package-data": "0.4"
"glob": "^7.1.1",
"json-parse-better-errors": "^1.0.1",
"normalize-package-data": "^2.0.0",
"slash": "^1.0.0"
},
"devDependencies": {
"tap": "~0.2.5"
"standard": "^11.0.0",
"standard-version": "^4.3.0",
"tap": "^11.1.2"
},
"optionalDependencies": {
"graceful-fs": "2 || 3"
"graceful-fs": "^4.1.2"
},
"license": "ISC"
"license": "ISC",
"files": [
"read-json.js"
]
}
This diff is collapsed.
// vim: set softtabstop=16 shiftwidth=16:
var tap = require("tap")
var readJson = require("../")
var path = require("path")
var fs = require("fs")
var readme = fs.readFileSync(path.resolve(__dirname, "../README.md"), "utf8")
var package = require("../package.json")
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
fs.readFileSync(path.resolve(__dirname, '../.git/HEAD'))
isGit = true
} catch (e) {
isGit = false
isGit = false
}
console.error("basic test")
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)
})
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, package.version)
t.equal(data._id, data.name + "@" + data.version)
t.equal(data.name, package.name)
t.type(data.author, "object")
t.equal(data.readme, readme)
t.deepEqual(data.scripts, package.scripts)
t.equal(data.main, package.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,
package.optionalDependencies)
t.has(data.dependencies, package.optionalDependencies)
t.has(data.dependencies, package.dependencies)
t.deepEqual(data.devDependencies, package.devDependencies)
t.end()
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()
}
var tap = require('tap')
var readJson = require('../')
var path = require('path')
var p = path.resolve(__dirname, 'fixtures/badbinnonstring.json')
tap.test('non-string bin entries', function (t) {
var logmsgs = []
readJson(p, function (msg) { logmsgs.push([].slice.call(arguments)) }, function (er, data) {
t.comment(logmsgs.map(function (msg) { return 'Warning: ' + msg.join(' ') }).join('\n'))
t.like(er, null, 'no error from readJson')
t.end()
})
})
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()
})
})
// vim: set softtabstop=16 shiftwidth=16:
var tap = require("tap")
var readJson = require("../")
var path = require("path")
var fs = require("fs")
var tap = require('tap')
var readJson = require('../')
var path = require('path')
console.error("BOM test")
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()
})
})
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()
})
})
})
{
"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"
}
{
"name": "badbinnonstring-test",
"description": "my desc",
"repository": {
"type": "git",
"url": "git://github.com/npm/read-package-json.git"
},
"version": "0.0.1",
"readme": "hello world",
"bin": {
"key": {}
},
"license": "ISC"
}
{
"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"
}
#!/bin/sh
echo "Hello world"
\ No newline at end of file
{
"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"
}
{
'wrong': 'kind',
'of': 'quotes'
}
body {
height: yo mama
height: super tall
}
/**package
......@@ -33,5 +33,5 @@ body {
**/
html {
width: so fat
width: wow so wide
}
var childProcess = require('child_process')
var fs = require('fs')
var path = require('path')
var tap = require('tap')
var readJson = require('../')
var isGit
try {
fs.readFileSync(path.resolve(__dirname, '../.git/HEAD'))
isGit = true
} catch (e) {
isGit = false
}
if (isGit) {
tap.test('gitHead tests', function (t) {
t.plan(3)
const repoProjectName = 'read-package-json'
const repo = 'https://github.com/npm/' + repoProjectName + '.git'
var repoDirs = []
t.test('detached case', function (tt) {
var p = path.resolve(__dirname, '..', 'package.json')
readJson(p, function (er, data) {
if (er) throw er
tt.ok(data)
tt.similar(data.gitHead, /^[a-f0-9]{40}$/)
tt.end()
})
})
function testGitRepo (kind, extraRepoCommand, t) {
var repoDirName = repoProjectName + '-' + kind
var cmd = `cd ${__dirname} && git clone ${repo} ${repoDirName} && cd ${repoDirName}`
if (extraRepoCommand) cmd += ` && ${extraRepoCommand}`
childProcess.execSync(cmd)
repoDirs.push(repoDirName)
var p = path.resolve(__dirname, repoDirName, 'package.json')
readJson(p, function (er, data) {
if (er) throw er
t.ok(data)
t.similar(data.gitHead, /^[a-f0-9]{40}$/)
t.end()
})
}
t.test('basic case', function (tt) {
testGitRepo('basic', '', tt)
})
t.test('git-pack-refs vs gitHead', function (tt) {
testGitRepo('git-pack-refs', 'git pack-refs --all', tt)
})
t.tearDown(function () {
repoDirs.forEach(function (d) {
childProcess.execSync(`rm -rf ${path.resolve(__dirname, d)}`)
})
})
})
}
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()
})
})
// vim: set softtabstop=16 shiftwidth=16:
var path = require('path')
var tap = require('tap')
var readJson = require('../')
var path = require('path')
var fs = require('fs')
var expect =
{ name: 'read-package-json',
var expect = {
name: 'read-package-json',
version: '0.1.1',
author:
{ name: 'Isaac Z. Schlueter',
email: 'i@izs.me',
url: 'http://blog.izs.me/' },
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" },
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' },
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",
optionalDependencies: { npmlog: '0', 'graceful-fs': '~1.1.8' },
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!' }
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()
})
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()
})
readJson(__filename, function (er, d) {
t.same(d, expect)
t.end()
})
})
/**package
{
"name": "read-package-json",
......@@ -76,4 +81,3 @@ tap.test('from js', function (t) {
}
}
**/
// vim: set softtabstop=16 shiftwidth=16:
var tap = require("tap")
var readJson = require("../")
var path = require("path")
var fs = require("fs")
var p = path.resolve(__dirname, "fixtures/readmes/package.json")
var path = require('path')
var tap = require('tap')
var p = path.resolve(__dirname, 'fixtures/readmes/package.json')
var readJson = require('../')
var expect = {}
var expect = {
"name" : "readmes",
"version" : "99.999.999999999",
"readme" : "*markdown*\n",
"readmeFilename" : "README.md",
"description" : "*markdown*",
"_id" : "readmes@99.999.999999999"
'name': 'readmes',
'version': '99.999.999999999',
'readme': '*markdown*\n',
'readmeFilename': 'README.md',
'description': '*markdown*',
'_id': 'readmes@99.999.999999999'
}
console.error("readme test")
tap.test("readme test", function (t) {
readJson(p, function (er, data) {
if (er) throw er;
test(t, data)
})
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()
function test (t, data) {
t.deepEqual(data, expect)
t.end()
}