diff --git a/node_modules/init-package-json/README.md b/node_modules/init-package-json/README.md index bd64c1230986f..528acf355158a 100644 --- a/node_modules/init-package-json/README.md +++ b/node_modules/init-package-json/README.md @@ -23,7 +23,7 @@ var dir = process.cwd() var configData = { some: 'extra stuff' } // Any existing stuff from the package.json file is also exposed in the -// PromZard module as the `package` object. There will also be free +// PromZard module as the `package` object. There will also be three // vars for: // * `filename` path to the package.json file // * `basename` the tip of the package dir diff --git a/node_modules/init-package-json/init-package-json.js b/node_modules/init-package-json/init-package-json.js index 5b2889e55da6b..83e7342d0aa4f 100644 --- a/node_modules/init-package-json/init-package-json.js +++ b/node_modules/init-package-json/init-package-json.js @@ -103,7 +103,7 @@ function init (dir, input, config, cb) { if (!pkg.description) pkg.description = data.description - var d = JSON.stringify(pkg, null, 2) + '\n' + var d = JSON.stringify(updateDeps(pkg), null, 2) + '\n' function write (yes) { fs.writeFile(packageFile, d, 'utf8', function (er) { if (!er && yes && !config.get('silent')) { @@ -132,6 +132,20 @@ function init (dir, input, config, cb) { } +function updateDeps(depsData) { + // optionalDependencies don't need to be repeated in two places + if (depsData.dependencies) { + if (depsData.optionalDependencies) { + for (const name of Object.keys(depsData.optionalDependencies)) + delete depsData.dependencies[name] + } + if (Object.keys(depsData.dependencies).length === 0) + delete depsData.dependencies + } + + return depsData +} + // turn the objects into somewhat more humane strings. function unParsePeople (data) { if (data.author) data.author = unParsePerson(data.author) diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json index abf06969264e4..91c6bfba82049 100644 --- a/node_modules/init-package-json/package.json +++ b/node_modules/init-package-json/package.json @@ -1,6 +1,6 @@ { "name": "init-package-json", - "version": "2.0.1", + "version": "2.0.2", "main": "init-package-json.js", "scripts": { "test": "tap", diff --git a/package-lock.json b/package-lock.json index b2f6868dda655..e0399b3603d66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -377,7 +377,7 @@ "graceful-fs": "^4.2.3", "hosted-git-info": "^3.0.8", "ini": "^2.0.0", - "init-package-json": "^2.0.1", + "init-package-json": "^2.0.2", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "leven": "^3.1.0", @@ -3570,9 +3570,9 @@ } }, "node_modules/init-package-json": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.1.tgz", - "integrity": "sha512-UsbZSZZipVfK8HsWoOIdCJYKdhqe5J7A2qxPOcTQjP9jNYKAbHiDyPqjugJsLFJR5GmVHuY/Iyha3Dp9pNdF9g==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.2.tgz", + "integrity": "sha512-PO64kVeArePvhX7Ff0jVWkpnE1DfGRvaWcStYrPugcJz9twQGYibagKJuIMHCX7ENcp0M6LJlcjLBuLD5KeJMg==", "inBundle": true, "dependencies": { "glob": "^7.1.1", @@ -12048,9 +12048,9 @@ "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==" }, "init-package-json": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.1.tgz", - "integrity": "sha512-UsbZSZZipVfK8HsWoOIdCJYKdhqe5J7A2qxPOcTQjP9jNYKAbHiDyPqjugJsLFJR5GmVHuY/Iyha3Dp9pNdF9g==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.2.tgz", + "integrity": "sha512-PO64kVeArePvhX7Ff0jVWkpnE1DfGRvaWcStYrPugcJz9twQGYibagKJuIMHCX7ENcp0M6LJlcjLBuLD5KeJMg==", "requires": { "glob": "^7.1.1", "npm-package-arg": "^8.1.0", diff --git a/package.json b/package.json index 67aab55fe4c81..9f5b16bcafc50 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "graceful-fs": "^4.2.3", "hosted-git-info": "^3.0.8", "ini": "^2.0.0", - "init-package-json": "^2.0.1", + "init-package-json": "^2.0.2", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "leven": "^3.1.0",