Skip to content

Commit 7285e05

Browse files
committedJan 17, 2023
fix(aggregate-error): upgraded to the latest version
BREAKING CHANGE: due to the aggregate-error upgrade, thrown errors are no longer iterable, but instead list the errors under an `errors` property
1 parent 1bce937 commit 7285e05

6 files changed

+286
-141
lines changed
 

‎index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function verifyConditions(pluginConfig, context) {
3333
await verifyNpmAuth(npmrc, pkg, context);
3434
}
3535
} catch (error) {
36-
errors.push(...error);
36+
errors.push(...error.errors);
3737
}
3838

3939
if (errors.length > 0) {
@@ -53,7 +53,7 @@ export async function prepare(pluginConfig, context) {
5353
await verifyNpmAuth(npmrc, pkg, context);
5454
}
5555
} catch (error) {
56-
errors.push(...error);
56+
errors.push(...error.errors);
5757
}
5858

5959
if (errors.length > 0) {
@@ -75,7 +75,7 @@ export async function publish(pluginConfig, context) {
7575
await verifyNpmAuth(npmrc, pkg, context);
7676
}
7777
} catch (error) {
78-
errors.push(...error);
78+
errors.push(...error.errors);
7979
}
8080

8181
if (errors.length > 0) {
@@ -100,7 +100,7 @@ export async function addChannel(pluginConfig, context) {
100100
await verifyNpmAuth(npmrc, pkg, context);
101101
}
102102
} catch (error) {
103-
errors.push(...error);
103+
errors.push(...error.errors);
104104
}
105105

106106
if (errors.length > 0) {

‎package-lock.json

+205-78
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"dependencies": {
2121
"@semantic-release/error": "^3.0.0",
22-
"aggregate-error": "^3.0.0",
22+
"aggregate-error": "^4.0.1",
2323
"execa": "^6.1.0",
2424
"fs-extra": "^11.0.0",
2525
"lodash-es": "^4.17.21",

‎test/get-pkg.test.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ test("Verify name and version then return parsed package.json from a sub-directo
2727

2828
test("Throw error if missing package.json", async (t) => {
2929
const cwd = temporaryDirectory();
30-
const [error] = await t.throwsAsync(getPkg({}, { cwd }));
30+
const {
31+
errors: [error],
32+
} = await t.throwsAsync(getPkg({}, { cwd }));
3133

3234
t.is(error.name, "SemanticReleaseError");
3335
t.is(error.code, "ENOPKG");
@@ -37,7 +39,9 @@ test("Throw error if missing package name", async (t) => {
3739
const cwd = temporaryDirectory();
3840
await fs.outputJson(path.resolve(cwd, "package.json"), { version: "0.0.0" });
3941

40-
const [error] = await t.throwsAsync(getPkg({}, { cwd }));
42+
const {
43+
errors: [error],
44+
} = await t.throwsAsync(getPkg({}, { cwd }));
4145

4246
t.is(error.name, "SemanticReleaseError");
4347
t.is(error.code, "ENOPKGNAME");
@@ -47,7 +51,9 @@ test("Throw error if package.json is malformed", async (t) => {
4751
const cwd = temporaryDirectory();
4852
await fs.writeFile(path.resolve(cwd, "package.json"), "{name: 'package',}");
4953

50-
const [error] = await t.throwsAsync(getPkg({}, { cwd }));
54+
const {
55+
errors: [error],
56+
} = await t.throwsAsync(getPkg({}, { cwd }));
5157

5258
t.is(error.name, "JSONError");
5359
});

‎test/integration.test.js

+64-54
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ test("Throws error if NPM token is invalid", async (t) => {
9696
const pkg = { name: "published", version: "1.0.0", publishConfig: { registry: npmRegistry.url } };
9797
await fs.outputJson(path.resolve(cwd, "package.json"), pkg);
9898

99-
const [error] = await t.throwsAsync(
99+
const {
100+
errors: [error],
101+
} = await t.throwsAsync(
100102
t.context.m.verifyConditions(
101103
{},
102104
{ cwd, env, options: {}, stdout: t.context.stdout, stderr: t.context.stderr, logger: t.context.logger }
@@ -186,21 +188,23 @@ test("Throw SemanticReleaseError Array if config option are not valid in verifyC
186188
const tarballDir = 42;
187189
const pkgRoot = 42;
188190
const errors = [
189-
...(await t.throwsAsync(
190-
t.context.m.verifyConditions(
191-
{},
192-
{
193-
cwd,
194-
env: {},
195-
options: {
196-
publish: ["@semantic-release/github", { path: "@semantic-release/npm", npmPublish, tarballDir, pkgRoot }],
197-
},
198-
stdout: t.context.stdout,
199-
stderr: t.context.stderr,
200-
logger: t.context.logger,
201-
}
191+
...(
192+
await t.throwsAsync(
193+
t.context.m.verifyConditions(
194+
{},
195+
{
196+
cwd,
197+
env: {},
198+
options: {
199+
publish: ["@semantic-release/github", { path: "@semantic-release/npm", npmPublish, tarballDir, pkgRoot }],
200+
},
201+
stdout: t.context.stdout,
202+
stderr: t.context.stderr,
203+
logger: t.context.logger,
204+
}
205+
)
202206
)
203-
)),
207+
).errors,
204208
];
205209

206210
t.is(errors[0].name, "SemanticReleaseError");
@@ -411,20 +415,22 @@ test("Throw SemanticReleaseError Array if config option are not valid in publish
411415
const pkgRoot = 42;
412416

413417
const errors = [
414-
...(await t.throwsAsync(
415-
t.context.m.publish(
416-
{ npmPublish, tarballDir, pkgRoot },
417-
{
418-
cwd,
419-
env: {},
420-
options: { publish: ["@semantic-release/github", "@semantic-release/npm"] },
421-
nextRelease: { version: "1.0.0" },
422-
stdout: t.context.stdout,
423-
stderr: t.context.stderr,
424-
logger: t.context.logger,
425-
}
418+
...(
419+
await t.throwsAsync(
420+
t.context.m.publish(
421+
{ npmPublish, tarballDir, pkgRoot },
422+
{
423+
cwd,
424+
env: {},
425+
options: { publish: ["@semantic-release/github", "@semantic-release/npm"] },
426+
nextRelease: { version: "1.0.0" },
427+
stdout: t.context.stdout,
428+
stderr: t.context.stderr,
429+
logger: t.context.logger,
430+
}
431+
)
426432
)
427-
)),
433+
).errors,
428434
];
429435

430436
t.is(errors[0].name, "SemanticReleaseError");
@@ -492,20 +498,22 @@ test("Throw SemanticReleaseError Array if config option are not valid in prepare
492498
const pkgRoot = 42;
493499

494500
const errors = [
495-
...(await t.throwsAsync(
496-
t.context.m.prepare(
497-
{ npmPublish, tarballDir, pkgRoot },
498-
{
499-
cwd,
500-
env: {},
501-
options: { publish: ["@semantic-release/github", "@semantic-release/npm"] },
502-
nextRelease: { version: "1.0.0" },
503-
stdout: t.context.stdout,
504-
stderr: t.context.stderr,
505-
logger: t.context.logger,
506-
}
501+
...(
502+
await t.throwsAsync(
503+
t.context.m.prepare(
504+
{ npmPublish, tarballDir, pkgRoot },
505+
{
506+
cwd,
507+
env: {},
508+
options: { publish: ["@semantic-release/github", "@semantic-release/npm"] },
509+
nextRelease: { version: "1.0.0" },
510+
stdout: t.context.stdout,
511+
stderr: t.context.stderr,
512+
logger: t.context.logger,
513+
}
514+
)
507515
)
508-
)),
516+
).errors,
509517
];
510518

511519
t.is(errors[0].name, "SemanticReleaseError");
@@ -677,20 +685,22 @@ test("Throw SemanticReleaseError Array if config option are not valid in addChan
677685
const pkgRoot = 42;
678686

679687
const errors = [
680-
...(await t.throwsAsync(
681-
t.context.m.addChannel(
682-
{ npmPublish, tarballDir, pkgRoot },
683-
{
684-
cwd,
685-
env,
686-
options: { publish: ["@semantic-release/github", "@semantic-release/npm"] },
687-
nextRelease: { version: "1.0.0" },
688-
stdout: t.context.stdout,
689-
stderr: t.context.stderr,
690-
logger: t.context.logger,
691-
}
688+
...(
689+
await t.throwsAsync(
690+
t.context.m.addChannel(
691+
{ npmPublish, tarballDir, pkgRoot },
692+
{
693+
cwd,
694+
env,
695+
options: { publish: ["@semantic-release/github", "@semantic-release/npm"] },
696+
nextRelease: { version: "1.0.0" },
697+
stdout: t.context.stdout,
698+
stderr: t.context.stderr,
699+
logger: t.context.logger,
700+
}
701+
)
692702
)
693-
)),
703+
).errors,
694704
];
695705

696706
t.is(errors[0].name, "SemanticReleaseError");

‎test/set-npmrc-auth.test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ test.serial('Throw error if "NPM_TOKEN" is missing', async (t) => {
117117
const npmrc = temporaryFile({ name: ".npmrc" });
118118

119119
const setNpmrcAuth = (await import("../lib/set-npmrc-auth.js")).default;
120-
const [error] = await t.throwsAsync(
120+
const {
121+
errors: [error],
122+
} = await t.throwsAsync(
121123
setNpmrcAuth(npmrc, "http://custom.registry.com", { cwd, env: {}, logger: t.context.logger })
122124
);
123125

0 commit comments

Comments
 (0)
Please sign in to comment.