summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar natemoo-re <natemoo-re@users.noreply.github.com> 2022-09-08 22:05:06 +0000
committerGravatar fredkbot <fred+astrobot@astro.build> 2022-09-08 22:05:06 +0000
commit65d753488e9a8b3dca6247fe00dfb8c89f28998f (patch)
tree4003c94fbec5a00e4194ddd8f21a6de9be0a93a3
parentfcb9a05c315e38838b1c1a84b959fd0810335d6e (diff)
downloadastro-65d753488e9a8b3dca6247fe00dfb8c89f28998f.tar.gz
astro-65d753488e9a8b3dca6247fe00dfb8c89f28998f.tar.zst
astro-65d753488e9a8b3dca6247fe00dfb8c89f28998f.zip
[ci] format
-rw-r--r--packages/astro/src/core/add/index.ts7
-rw-r--r--packages/astro/src/runtime/server/serialize.ts8
-rw-r--r--packages/astro/test/serialize.test.js36
3 files changed, 28 insertions, 23 deletions
diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts
index 526238691..779349999 100644
--- a/packages/astro/src/core/add/index.ts
+++ b/packages/astro/src/core/add/index.ts
@@ -577,9 +577,10 @@ async function tryToInstallIntegrations({
if (installCommand === null) {
return UpdateResult.none;
} else {
- const coloredOutput = `${bold(installCommand.pm)} ${
- installCommand.command
- }${['', ...installCommand.flags].join(' ')} ${cyan(installCommand.dependencies.join(' '))}`;
+ const coloredOutput = `${bold(installCommand.pm)} ${installCommand.command}${[
+ '',
+ ...installCommand.flags,
+ ].join(' ')} ${cyan(installCommand.dependencies.join(' '))}`;
const message = `\n${boxen(coloredOutput, {
margin: 0.5,
padding: 0.5,
diff --git a/packages/astro/src/runtime/server/serialize.ts b/packages/astro/src/runtime/server/serialize.ts
index 024a689b0..021c050da 100644
--- a/packages/astro/src/runtime/server/serialize.ts
+++ b/packages/astro/src/runtime/server/serialize.ts
@@ -13,7 +13,11 @@ const PROP_TYPE = {
URL: 7,
};
-function serializeArray(value: any[], metadata: AstroComponentMetadata | Record<string, any> = {}, parents = new WeakSet<any>()): any[] {
+function serializeArray(
+ value: any[],
+ metadata: AstroComponentMetadata | Record<string, any> = {},
+ parents = new WeakSet<any>()
+): any[] {
if (parents.has(value)) {
throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>!
@@ -21,7 +25,7 @@ Cyclic references cannot be safely serialized for client-side usage. Please remo
}
parents.add(value);
const serialized = value.map((v) => {
- return convertToSerializedForm(v, metadata, parents)
+ return convertToSerializedForm(v, metadata, parents);
});
parents.delete(value);
return serialized;
diff --git a/packages/astro/test/serialize.test.js b/packages/astro/test/serialize.test.js
index ad28638b2..0646edfd7 100644
--- a/packages/astro/test/serialize.test.js
+++ b/packages/astro/test/serialize.test.js
@@ -6,62 +6,62 @@ describe('serialize', () => {
const input = { a: 1 };
const output = `{"a":[0,1]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('serializes an array', () => {
const input = { a: [0] };
const output = `{"a":[1,"[[0,0]]"]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('serializes a regular expression', () => {
const input = { a: /b/ };
const output = `{"a":[2,"b"]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('serializes a Date', () => {
const input = { a: new Date(0) };
const output = `{"a":[3,"1970-01-01T00:00:00.000Z"]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('serializes a Map', () => {
const input = { a: new Map([[0, 1]]) };
const output = `{"a":[4,"[[1,\\"[[0,0],[0,1]]\\"]]"]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('serializes a Set', () => {
const input = { a: new Set([0, 1, 2, 3]) };
const output = `{"a":[5,"[[0,0],[0,1],[0,2],[0,3]]"]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('serializes a BigInt', () => {
const input = { a: BigInt('1') };
const output = `{"a":[6,"1"]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('serializes a URL', () => {
const input = { a: new URL('https://example.com/') };
const output = `{"a":[7,"https://example.com/"]}`;
expect(serializeProps(input)).to.equal(output);
- })
+ });
it('cannot serialize a cyclic reference', () => {
- const a = {}
+ const a = {};
a.b = a;
const input = { a };
expect(() => serializeProps(input)).to.throw(/cyclic/);
- })
+ });
it('cannot serialize a cyclic array', () => {
- const input = { foo: ['bar'] }
- input.foo.push(input)
+ const input = { foo: ['bar'] };
+ input.foo.push(input);
expect(() => serializeProps(input)).to.throw(/cyclic/);
- })
+ });
it('cannot serialize a deep cyclic reference', () => {
- const a = { b: {}};
+ const a = { b: {} };
a.b.c = a;
const input = { a };
expect(() => serializeProps(input)).to.throw(/cyclic/);
- })
+ });
it('can serialize shared references that are not cyclic', () => {
- const b = {}
+ const b = {};
const input = { a: { b, b }, b };
expect(() => serializeProps(input)).not.to.throw();
- })
-})
+ });
+});