+26
-5
lines changedFilter options
+26
-5
lines changed Original file line number Diff line number Diff line change
@@ -109,13 +109,17 @@ class Unpublish extends BaseCommand {
109
109
const { content } = await pkgJson.prepare(localPrefix)
110
110
manifest = content
111
111
} catch (err) {
112
-
// we needed the manifest to figure out the package to unpublish
113
-
if (!spec) {
114
-
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
112
+
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
113
+
if (!spec) {
114
+
// We needed a local package.json to figure out what package to
115
+
// unpublish
115
116
throw this.usageError()
116
-
} else {
117
-
throw err
118
117
}
118
+
} else {
119
+
// folks should know if ANY local package.json had a parsing error.
120
+
// They may be relying on `publishConfig` to be loading and we don't
121
+
// want to ignore errors in that case.
122
+
throw err
119
123
}
120
124
}
121
125
Original file line number Diff line number Diff line change
@@ -63,6 +63,23 @@ t.test('no args --force error reading package.json', async t => {
63
63
)
64
64
})
65
65
66
+
t.test('with args --force error reading package.json', async t => {
67
+
const { npm } = await loadMockNpm(t, {
68
+
config: {
69
+
force: true,
70
+
},
71
+
prefixDir: {
72
+
'package.json': '{ not valid json ]',
73
+
},
74
+
})
75
+
76
+
await t.rejects(
77
+
npm.exec('unpublish', [pkg]),
78
+
/Invalid package.json/,
79
+
'should throw error from reading package.json'
80
+
)
81
+
})
82
+
66
83
t.test('no force entire project', async t => {
67
84
const { npm } = await loadMockNpm(t)
68
85
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4