node/deps/npm/lib/install/update-package-json.js
Rebecca Turner 41923c0c07 deps: upgrade npm to 3.3.6
PR-URL: https://github.com/nodejs/node/pull/3310
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-22 13:56:09 -04:00

19 lines
829 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict'
var path = require('path')
var writeFileAtomic = require('write-file-atomic')
var deepSortObject = require('../utils/deep-sort-object.js')
module.exports = function (pkg, buildpath, next) {
// FIXME: This bundled dance is because we're sticking a big tree of bundled
// deps into the parsed package.json it probably doesn't belong there =/
// But the real reason we don't just dump it out is that it's the result
// of npm-read-tree, which produces circular data structures, due to the
// parent and children keys.
var bundled = pkg.package._bundled
delete pkg.package._bundled // FIXME
var packagejson = deepSortObject(pkg.package)
var data = JSON.stringify(packagejson, null, 2) + '\n'
pkg.package._bundled = bundled
writeFileAtomic(path.resolve(buildpath, 'package.json'), data, next)
}