Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-package-json

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-package-json - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

2

package.json
{
"name": "read-package-json",
"version": "0.1.9",
"version": "0.1.10",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",

@@ -5,0 +5,0 @@ "description": "The thing npm uses to read package.json files with semantics and defaults and validation",

@@ -32,3 +32,12 @@ // vim: set softtabstop=16 shiftwidth=16:

// put more stuff on here to customize.
readJson.extraSet = [gypfile, wscript, serverjs, authors, readme, mans, bins]
readJson.extraSet = [
gypfile,
wscript,
serverjs,
authors,
readme,
mans,
bins,
githead
]

@@ -307,2 +316,37 @@ var typoWarned = {}

function githead (file, data, cb) {
if (data.gitHead) return cb(null, data);
var dir = path.dirname(file)
var head = path.resolve(dir, '.git/HEAD')
fs.readFile(head, 'utf8', function (er, head) {
if (er) return cb(null, data);
githead_(file, data, dir, head, cb)
})
}
function githead_ (file, data, dir, head, cb) {
if (!head.match(/^ref: /)) {
data.gitHead = head.trim()
return cb(null, data)
}
var headFile = head.replace(/^ref: /, '').trim()
headFile = path.resolve(dir, '.git', headFile)
fs.readFile(headFile, 'utf8', function (er, head) {
head = head.replace(/^ref: /, '').trim()
data.gitHead = head
return cb(null, data)
})
}
try {
gitHead = fs.readFileSync('.git/HEAD', 'utf8').trim()
if (gitHead.match(/^ref: /)) {
gitHead = gitHead.replace(/^ref: /, '').trim()
gitHead = fs.readFileSync('.git/' + gitHead, 'utf8').trim()
}
config.HEAD = gitHead
} catch (_) {
gitHead = '(not a git repo) ' + _.message
}
function final (file, data, cb) {

@@ -309,0 +353,0 @@ var ret = validName(file, data)

@@ -8,2 +8,9 @@ // vim: set softtabstop=16 shiftwidth=16:

var package = require("../package.json")
var isGit
try {
fs.readFileSync(path.resolve(__dirname, '../.git/HEAD'));
isGit = true
} catch (e) {
isGit = false
}

@@ -29,2 +36,4 @@ console.error("basic test")

if (isGit) t.similar(data.gitHead, /^[a-f0-9]{40}$/);
// optional deps are folded in.

@@ -31,0 +40,0 @@ t.deepEqual(data.optionalDependencies,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc