[ci] format

This commit is contained in:
matthewp 2023-09-08 14:02:12 +00:00 committed by astrobot-houston
parent 7eea37a075
commit b65e84d888
2 changed files with 10 additions and 7 deletions

View file

@ -58,10 +58,10 @@ export default function configHeadVitePlugin(): vite.Plugin {
propagateMetadata.call(this, id, 'containsHead', true); propagateMetadata.call(this, id, 'containsHead', true);
} }
if(info && getAstroMetadata(info)?.propagation === 'self') { if (info && getAstroMetadata(info)?.propagation === 'self') {
const mod = server.moduleGraph.getModuleById(id); const mod = server.moduleGraph.getModuleById(id);
for (const parent of mod?.importers ?? []) { for (const parent of mod?.importers ?? []) {
if(parent.id) { if (parent.id) {
propagateMetadata.call(this, parent.id, 'propagation', 'in-tree'); propagateMetadata.call(this, parent.id, 'propagation', 'in-tree');
} }
} }
@ -100,18 +100,18 @@ export function astroHeadBuildPlugin(internals: BuildInternals): AstroBuildPlugi
const modinfo = this.getModuleInfo(id); const modinfo = this.getModuleInfo(id);
// <head> tag in the tree // <head> tag in the tree
if(modinfo) { if (modinfo) {
const meta = getAstroMetadata(modinfo); const meta = getAstroMetadata(modinfo);
if(meta?.containsHead) { if (meta?.containsHead) {
for (const [pageInfo] of getTopLevelPages(id, this)) { for (const [pageInfo] of getTopLevelPages(id, this)) {
let metadata = getOrCreateMetadata(pageInfo.id); let metadata = getOrCreateMetadata(pageInfo.id);
metadata.containsHead = true; metadata.containsHead = true;
} }
} }
if(meta?.propagation === 'self') { if (meta?.propagation === 'self') {
for (const [info] of walkParentInfos(id, this)) { for (const [info] of walkParentInfos(id, this)) {
let metadata = getOrCreateMetadata(info.id); let metadata = getOrCreateMetadata(info.id);
if(metadata.propagation !== 'self') { if (metadata.propagation !== 'self') {
metadata.propagation = 'in-tree'; metadata.propagation = 'in-tree';
} }
} }

View file

@ -179,7 +179,10 @@ describe('head injection', () => {
const html = await text(); const html = await text();
const $ = cheerio.load(html); const $ = cheerio.load(html);
expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(1, 'found inner link'); expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(
1,
'found inner link'
);
expect($('#other')).to.have.a.lengthOf(1, 'Found the #other div'); expect($('#other')).to.have.a.lengthOf(1, 'Found the #other div');
} }
); );