Permalink
Browse files

Use read-package-json dep

  • Loading branch information...
1 parent 86fd553 commit 99110432e5a0315ba1c0c69679bb5e07438b6be2 @isaacs isaacs committed Jun 11, 2012
View
@@ -6,7 +6,7 @@ if (argv.length < 3) {
var fs = require("fs")
, file = argv[2]
- , readJson = require("../lib/utils/read-json")
+ , readJson = require("read-package-json")
readJson(file, function (er, data) {
if (er) throw er
View
@@ -14,7 +14,7 @@ var npm = require("./npm.js")
, fs = require("graceful-fs")
, path = require("path")
, lifecycle = require("./utils/lifecycle.js")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, link = require("./utils/link.js")
, linkIfExists = link.ifExists
, cmdShim = require("./utils/cmd-shim.js")
View
@@ -37,7 +37,7 @@ var mkdir = require("mkdirp")
, npm = require("./npm.js")
, fs = require("graceful-fs")
, rm = require("rimraf")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, registry = npm.registry
, log = require("npmlog")
, path = require("path")
View
@@ -5,7 +5,7 @@ module.exports = init
var read = require("read")
, path = require("path")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, fs = require("graceful-fs")
, promiseChain = require("./utils/promise-chain.js")
, exec = require("./utils/exec.js")
@@ -150,12 +150,6 @@ function init_ (data, folder, cb) {
)
(cleanupPaths, [data, folder])
(function (cb) {
- try { data = readJson.processJson(data) }
- catch (er) { return cb(er) }
- Object.keys(data)
- .filter(function (k) { return k.match(/^_/) })
- .forEach(function (k) { delete data[k] })
- readJson.unParsePeople(data)
var str = JSON.stringify(data, null, 2)
, msg = "About to write to "
+ path.join(folder, "package.json")
View
@@ -57,7 +57,7 @@ install.completion = function (opts, cb) {
var npm = require("./npm.js")
, semver = require("semver")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, log = require("npmlog")
, path = require("path")
, fs = require("graceful-fs")
@@ -174,10 +174,15 @@ function readDependencies (context, where, opts, cb) {
var wrap = context ? context.wrap : null
readJson( path.resolve(where, "package.json")
- , opts
, function (er, data) {
if (er) return cb(er)
+ if (opts && opts.dev) {
+ Object.keys(data.devDependencies || {}).forEach(function (k) {
+ data.dependencies[k] = data.devDependencies[k]
+ })
+ }
+
if (wrap) {
log.verbose("readDependencies: using existing wrap", [where, wrap])
var rv = {}
View
@@ -114,13 +114,11 @@ function linkInstall (pkgs, cb) {
function linkPkg (folder, cb_) {
var me = folder || npm.prefix
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
log.verbose("linkPkg", folder)
- readJson( path.resolve(me, "package.json")
- , { dev: true }
- , function (er, d) {
+ readJson(path.resolve(me, "package.json"), function (er, d) {
function cb (er) {
return cb_(er, [[d && d._id, target, null, null]])
}
View
@@ -20,7 +20,7 @@ outdated.completion = require("./utils/completion/installed-deep.js")
var path = require("path")
, fs = require("graceful-fs")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, cache = require("./cache.js")
, asyncMap = require("slide").asyncMap
, npm = require("./npm.js")
@@ -89,8 +89,8 @@ function outdated_ (args, dir, parentHas, cb) {
return next()
}
asyncMap(pkgs, function (pkg, cb) {
- readJson( path.resolve(dir, "node_modules", pkg, "package.json")
- , function (er, d) {
+ var jsonFile = path.resolve(dir, "node_modules", pkg, "package.json")
+ readJson(jsonFile, function (er, d) {
cb(null, er ? [] : [[d.name, d.version]])
})
}, function (er, pvs) {
View
@@ -68,6 +68,7 @@ var npm = require("./npm.js")
, registry = npm.registry
, log = require("npmlog")
, output
+ , readJson = require("read-package-json")
function owner (args, cb) {
var action = args.shift()
@@ -189,7 +190,6 @@ function mutate (pkg, user, mutation, cb) {
function readLocalPkg (cb) {
if (npm.config.get("global")) return cb()
var path = require("path")
- , readJson = require("./utils/read-json.js")
readJson(path.resolve(npm.prefix, "package.json"), function (er, d) {
return cb(er, d && d.name)
})
View
@@ -7,7 +7,7 @@ var npm = require("./npm.js")
, tar = require("./utils/tar.js")
, sha = require("./utils/sha.js")
, path = require("path")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, fs = require("graceful-fs")
, lifecycle = require("./utils/lifecycle.js")
, chain = require("slide").chain
@@ -39,6 +39,8 @@ function publish (args, isRetry, cb) {
// to the cache.
if (er) return cacheAddPublish(arg, false, isRetry, cb)
+ data._npmUser = { name: npm.config.get("username")
+ , email: npm.config.get("email") }
cacheAddPublish(arg, true, isRetry, cb)
})
}
View
@@ -4,7 +4,7 @@ module.exports = runScript
var lifecycle = require("./utils/lifecycle.js")
, npm = require("./npm.js")
, path = require("path")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, log = require("npmlog")
, chain = require("slide").chain
, fs = require("graceful-fs")
@@ -34,8 +34,6 @@ runScript.completion = function (opts, cb) {
: npm.prefix
var pkgDir = path.resolve( pref, "node_modules"
, argv[2], "package.json" )
- console.error("global?", npm.config.get("global"))
- console.error(pkgDir, "package dir")
readJson(pkgDir, function (er, d) {
if (er) d = {}
var scripts = Object.keys(d.scripts || {})
View
@@ -5,7 +5,6 @@
module.exports = submodule
var npm = require("./npm.js")
- , readJson = require("./utils/read-json.js")
, exec = require("./utils/exec.js")
, output = require("./utils/output.js")
, cache = require("./cache.js")
View
@@ -1,7 +1,7 @@
module.exports = unbuild
unbuild.usage = "npm unbuild <folder>\n(this is plumbing)"
-var readJson = require("./utils/read-json.js")
+var readJson = require("read-package-json")
, rm = require("rimraf")
, gentlyRm = require("./utils/gently-rm.js")
, npm = require("./npm.js")
@@ -24,7 +24,7 @@ function unbuild_ (folder, cb) {
readJson(path.resolve(folder, "package.json"), function (er, pkg) {
// if no json, then just trash it, but no scripts or whatever.
if (er) return rm(folder, cb)
- readJson.clearCache(folder)
+ readJson.cache.del(folder)
chain
( [ [lifecycle, pkg, "preuninstall", folder, false, true]
, [lifecycle, pkg, "uninstall", folder, false, true]
View
@@ -10,7 +10,7 @@ uninstall.completion = require("./utils/completion/installed-shallow.js")
var fs = require("graceful-fs")
, log = require("npmlog")
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, path = require("path")
, npm = require("./npm.js")
, semver = require("semver")
View
@@ -4,7 +4,7 @@ module.exports = unpublish
var log = require("npmlog")
, npm = require("./npm.js")
, registry = npm.registry
- , readJson = require("./utils/read-json.js")
+ , readJson = require("read-package-json")
, path = require("path")
, output = require("./utils/output.js")
@@ -4,7 +4,7 @@ module.exports = installedShallow
var npm = require("../../npm.js")
, fs = require("graceful-fs")
, path = require("path")
- , readJson = require("../read-json.js")
+ , readJson = require("read-package-json")
, asyncMap = require("slide").asyncMap
function installedShallow (opts, filter, cb) {
View
@@ -6,7 +6,6 @@ var log = require("npmlog")
, exec = require("./exec.js")
, npm = require("../npm.js")
, path = require("path")
- , readJson = require("./read-json.js")
, fs = require("graceful-fs")
, chain = require("slide").chain
, constants = require("constants")
@@ -92,7 +92,7 @@ var npm = require("../npm.js")
, path = require("path")
, asyncMap = require("slide").asyncMap
, semver = require("semver")
- , readJson = require("./read-json.js")
+ , readJson = require("read-package-json")
, log = require("npmlog")
, url = require("url")
Oops, something went wrong.

0 comments on commit 9911043

Please sign in to comment.