0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] npm run format

This commit is contained in:
matthewp 2021-03-30 14:52:09 +00:00 committed by GitHub Actions
parent 3b27eaac43
commit d267fa461b
9 changed files with 24 additions and 29 deletions

View file

@ -8,26 +8,27 @@ export default function (_opts: { filename: string; fileID: string }): Optimizer
html: { html: {
Element: { Element: {
enter(node, parent, _key, index) { enter(node, parent, _key, index) {
if(node.name === '!doctype') { if (node.name === '!doctype') {
hasDoctype = true; hasDoctype = true;
} }
if(node.name === 'html' && !hasDoctype) { if (node.name === 'html' && !hasDoctype) {
const dtNode = { const dtNode = {
start: 0, end: 0, start: 0,
end: 0,
attributes: [{ type: 'Attribute', name: 'html', value: true, start: 0, end: 0 }], attributes: [{ type: 'Attribute', name: 'html', value: true, start: 0, end: 0 }],
children: [], children: [],
name: '!doctype', name: '!doctype',
type: 'Element' type: 'Element',
}; };
parent.children!.splice(index, 0, dtNode); parent.children!.splice(index, 0, dtNode);
hasDoctype = true; hasDoctype = true;
} }
} },
} },
} },
}, },
async finalize() { async finalize() {
// Nothing happening here. // Nothing happening here.
} },
} };
} }

View file

@ -6,9 +6,9 @@ export type HTag = string | AstroComponent;
const voidTags = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']); const voidTags = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
function* _h(tag: string, attrs: HProps, children: Array<HChild>) { function* _h(tag: string, attrs: HProps, children: Array<HChild>) {
if(tag === '!doctype') { if (tag === '!doctype') {
yield '<!doctype '; yield '<!doctype ';
if(attrs) { if (attrs) {
yield Object.keys(attrs).join(' '); yield Object.keys(attrs).join(' ');
} }
yield '>'; yield '>';

View file

@ -5,11 +5,7 @@ import type { CompileError } from './parser/utils/error.js';
import { info } from './logger.js'; import { info } from './logger.js';
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import { import { loadConfiguration, logger as snowpackLogger, startServer as startSnowpackServer } from 'snowpack';
loadConfiguration,
logger as snowpackLogger,
startServer as startSnowpackServer
} from 'snowpack';
interface RuntimeConfig { interface RuntimeConfig {
astroConfig: AstroConfig; astroConfig: AstroConfig;
@ -137,10 +133,10 @@ export async function createRuntime(astroConfig: AstroConfig, { logging }: Runti
const mountOptions = { const mountOptions = {
[astroRoot.pathname]: '/_astro', [astroRoot.pathname]: '/_astro',
[internalPath.pathname]: '/_astro_internal' [internalPath.pathname]: '/_astro_internal',
} };
if(existsSync(astroConfig.public)) { if (existsSync(astroConfig.public)) {
mountOptions[astroConfig.public.pathname] = '/'; mountOptions[astroConfig.public.pathname] = '/';
} }

View file

@ -16,7 +16,7 @@ Basics.before(async () => {
dest: process.stderr, dest: process.stderr,
}; };
runtime = await createRuntime(astroConfig, {logging}); runtime = await createRuntime(astroConfig, { logging });
}); });
Basics.after(async () => { Basics.after(async () => {

View file

@ -16,8 +16,7 @@ DType.before(async () => {
dest: process.stderr, dest: process.stderr,
}; };
runtime = await createRuntime(astroConfig, { logging });
runtime = await createRuntime(astroConfig, {logging});
} catch (err) { } catch (err) {
console.error(err); console.error(err);
setupError = err; setupError = err;
@ -47,8 +46,7 @@ DType.skip('Preserves user provided doctype', async () => {
assert.equal(result.statusCode, 200); assert.equal(result.statusCode, 200);
const html = result.contents.toString('utf-8'); const html = result.contents.toString('utf-8');
assert.ok(html.startsWith('<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'), assert.ok(html.startsWith('<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'), 'Doctype included was preserved');
'Doctype included was preserved');
}); });
DType.run(); DType.run();

View file

@ -17,7 +17,7 @@ Markdown.before(async () => {
}; };
try { try {
runtime = await createRuntime(astroConfig, {logging}); runtime = await createRuntime(astroConfig, { logging });
} catch (err) { } catch (err) {
console.error(err); console.error(err);
setupError = err; setupError = err;

View file

@ -16,7 +16,7 @@ StylesSSR.before(async () => {
dest: process.stderr, dest: process.stderr,
}; };
runtime = await createRuntime(astroConfig, {logging}); runtime = await createRuntime(astroConfig, { logging });
}); });
StylesSSR.after(async () => { StylesSSR.after(async () => {

View file

@ -17,7 +17,7 @@ React.before(async () => {
}; };
try { try {
runtime = await createRuntime(astroConfig, {logging}); runtime = await createRuntime(astroConfig, { logging });
} catch (err) { } catch (err) {
console.error(err); console.error(err);
setupError = err; setupError = err;

View file

@ -25,7 +25,7 @@ SnowpackDev.before(async () => {
}; };
try { try {
runtime = await createRuntime(astroConfig, {logging}); runtime = await createRuntime(astroConfig, { logging });
} catch (err) { } catch (err) {
console.error(err); console.error(err);
setupError = err; setupError = err;