From 8cc806cfe28ecbbecae9f7f3bc828d7eea6cd431 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 5 May 2019 12:12:50 +0300 Subject: [PATCH] feat: support exotic manifests Support package.json5 and package.yaml BREAKING CHANGE: Node.js>=8.15 is required --- .travis.yml | 5 +---- lib/read-package-json.js | 14 ++++++++------ package.json | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce269b4..f5dadc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,9 @@ sudo: false language: node_js node_js: - - "4.0.0" - - "4" - - "6" - "8" - "10" - - "11" + - "12" script: - npm test diff --git a/lib/read-package-json.js b/lib/read-package-json.js index 1497ebf..a53c4c8 100644 --- a/lib/read-package-json.js +++ b/lib/read-package-json.js @@ -10,8 +10,8 @@ // Requirements //------------------------------------------------------------------------------ -const joinPath = require("path").join -const readPkg = require("read-pkg") +const pathResolve = require("path").resolve +const readManifest = require("@pnpm/read-importer-manifest").default //------------------------------------------------------------------------------ // Public Interface @@ -23,9 +23,11 @@ const readPkg = require("read-pkg") * @returns {object} package.json's information. */ module.exports = function readPackageJson() { - const path = joinPath(process.cwd(), "package.json") - return readPkg(path).then(body => ({ - taskList: Object.keys(body.scripts || {}), - packageInfo: { path, body }, + return readManifest(process.cwd()).then(readResult => ({ + taskList: Object.keys(readResult.manifest.scripts || {}), + packageInfo: { + body: readResult.manifest, + path: pathResolve(readResult.fileName), + }, })) } diff --git a/package.json b/package.json index f130b86..48c9c6c 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "docs" ], "engines": { - "node": ">= 4" + "node": ">= 8.15" }, "scripts": { "_mocha": "mocha \"test/*.js\" --timeout 120000", @@ -29,13 +29,13 @@ "codecov": "nyc report -r lcovonly && codecov" }, "dependencies": { + "@pnpm/read-importer-manifest": "^1.0.0", "ansi-styles": "^3.2.1", "chalk": "^2.4.1", "cross-spawn": "^6.0.5", "memorystream": "^0.3.1", "minimatch": "^3.0.4", "pidtree": "^0.3.0", - "read-pkg": "^3.0.0", "shell-quote": "^1.6.1", "string.prototype.padend": "^3.0.0" },