From cd3c880a4678fa3737fa0baf41f4cf4c4c38f3df Mon Sep 17 00:00:00 2001 From: Nytelife26 Date: Sun, 11 Apr 2021 01:12:50 +0100 Subject: [PATCH 1/3] fix: support package.json private directive --- lib/util/check-publish.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/check-publish.js b/lib/util/check-publish.js index 08727b21..c92a9147 100644 --- a/lib/util/check-publish.js +++ b/lib/util/check-publish.js @@ -46,7 +46,7 @@ module.exports = function checkForPublish(context, filePath, targets) { ) ) - if (!npmignore.match(toRelative(filePath))) { + if (!npmignore.match(toRelative(filePath)) && !packageInfo.private) { // This file is published, so this cannot import private files. for (const target of targets) { const isPrivateFile = From 554fe965f71934f8895a7cd6b9e87952f16d7712 Mon Sep 17 00:00:00 2001 From: Nytelife26 Date: Sun, 11 Apr 2021 01:53:56 +0100 Subject: [PATCH 2/3] perf: return early in publish checking --- lib/util/check-publish.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util/check-publish.js b/lib/util/check-publish.js index c92a9147..8855a521 100644 --- a/lib/util/check-publish.js +++ b/lib/util/check-publish.js @@ -22,7 +22,7 @@ const getPackageJson = require("./get-package-json") */ module.exports = function checkForPublish(context, filePath, targets) { const packageInfo = getPackageJson(filePath) - if (!packageInfo) { + if (!packageInfo || packageInfo.private) { return } @@ -46,7 +46,7 @@ module.exports = function checkForPublish(context, filePath, targets) { ) ) - if (!npmignore.match(toRelative(filePath)) && !packageInfo.private) { + if (!npmignore.match(toRelative(filePath))) { // This file is published, so this cannot import private files. for (const target of targets) { const isPrivateFile = From b09a2d841eca00f95b7a5eeb3c01d92f92a83937 Mon Sep 17 00:00:00 2001 From: Nytelife26 Date: Sun, 11 Apr 2021 01:58:00 +0100 Subject: [PATCH 3/3] test: fix ci failure due to ignored private --- tests/fixtures/no-unpublished/1/package.json | 3 +-- tests/fixtures/no-unpublished/2/package.json | 3 +-- tests/fixtures/no-unpublished/3/package.json | 3 +-- tests/fixtures/no-unpublished/issue126/package.json | 1 - tests/fixtures/no-unpublished/negative-in-files/package.json | 1 - 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/fixtures/no-unpublished/1/package.json b/tests/fixtures/no-unpublished/1/package.json index c8fdd873..2347b88b 100644 --- a/tests/fixtures/no-unpublished/1/package.json +++ b/tests/fixtures/no-unpublished/1/package.json @@ -1,5 +1,4 @@ { - "private": true, "name": "test", "version": "0.0.0", "dependencies": { @@ -8,4 +7,4 @@ "devDependencies": { "bbb": "0.0.0" } -} \ No newline at end of file +} diff --git a/tests/fixtures/no-unpublished/2/package.json b/tests/fixtures/no-unpublished/2/package.json index c8fdd873..2347b88b 100644 --- a/tests/fixtures/no-unpublished/2/package.json +++ b/tests/fixtures/no-unpublished/2/package.json @@ -1,5 +1,4 @@ { - "private": true, "name": "test", "version": "0.0.0", "dependencies": { @@ -8,4 +7,4 @@ "devDependencies": { "bbb": "0.0.0" } -} \ No newline at end of file +} diff --git a/tests/fixtures/no-unpublished/3/package.json b/tests/fixtures/no-unpublished/3/package.json index 374e4e50..b03210fb 100644 --- a/tests/fixtures/no-unpublished/3/package.json +++ b/tests/fixtures/no-unpublished/3/package.json @@ -1,5 +1,4 @@ { - "private": true, "name": "test", "version": "0.0.0", "files": ["pub"], @@ -9,4 +8,4 @@ "devDependencies": { "bbb": "0.0.0" } -} \ No newline at end of file +} diff --git a/tests/fixtures/no-unpublished/issue126/package.json b/tests/fixtures/no-unpublished/issue126/package.json index 85a25a9d..11bec50f 100644 --- a/tests/fixtures/no-unpublished/issue126/package.json +++ b/tests/fixtures/no-unpublished/issue126/package.json @@ -1,5 +1,4 @@ { - "private": true, "name": "test", "version": "0.0.0", "files": [ diff --git a/tests/fixtures/no-unpublished/negative-in-files/package.json b/tests/fixtures/no-unpublished/negative-in-files/package.json index 9c2cf99d..00347553 100644 --- a/tests/fixtures/no-unpublished/negative-in-files/package.json +++ b/tests/fixtures/no-unpublished/negative-in-files/package.json @@ -1,5 +1,4 @@ { - "private": true, "name": "test", "version": "0.0.0", "files": [