Skip to content

Commit 21c3783

Browse files
committed
Another glob is globbed too soon
1 parent 8a0df30 commit 21c3783

File tree

4 files changed

+40
-32
lines changed

4 files changed

+40
-32
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"test": "jest",
1010
"pretest": "npm run check && npm run build && prettier --check src/**/*.js",
1111
"prepublishOnly": "npm test",
12-
"format": "prettier --write src/**/*.js"
12+
"format": "prettier --write 'src/**/*.js'"
1313
},
1414
"repository": {
1515
"type": "git",

src/index.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function createPlugin() {
176176
replaceColor,
177177
extensionDataDirectory,
178178
logLevel,
179-
...rest,
179+
...rest
180180
});
181181

182182
/** @type {Record<string, string>} */
@@ -227,7 +227,11 @@ function createPlugin() {
227227

228228
const themeClassName = themeClassNames[setting];
229229
const themeCache = await cache.get('themes');
230-
const colorThemePath = ensureThemeLocation(colorThemeIdentifier, themeCache, markdownNode.fileAbsolutePath);
230+
const colorThemePath = await ensureThemeLocation(
231+
colorThemeIdentifier,
232+
themeCache,
233+
markdownNode.fileAbsolutePath
234+
);
231235

232236
const { resultRules: tokenColors, resultColors: settings } = loadColorTheme(colorThemePath);
233237
const defaultTokenColors = {
@@ -310,9 +314,9 @@ function createPlugin() {
310314
const endIndex = result.tokens[i + 2] || line.length;
311315
/** @type {LineData} */
312316
htmlLine.push(
313-
span({ class: getClassNameFromMetadata(metadata) }, [
314-
escapeHTML(line.slice(startIndex, endIndex))
315-
], { whitespace: TriviaRenderFlags.NoWhitespace }),
317+
span({ class: getClassNameFromMetadata(metadata) }, [escapeHTML(line.slice(startIndex, endIndex))], {
318+
whitespace: TriviaRenderFlags.NoWhitespace
319+
})
316320
);
317321
}
318322
} else {
@@ -321,24 +325,25 @@ function createPlugin() {
321325

322326
/** @type {LineData} */
323327
const lineData = { codeFenceOptions: options, index: lineIndex, content: line, language: languageName };
324-
const className = joinClassNames(
325-
getLineClassName(lineData),
326-
'vscode-highlight-line'
327-
);
328+
const className = joinClassNames(getLineClassName(lineData), 'vscode-highlight-line');
328329

329-
htmlLines.push(span(
330-
mergeAttributes({ class: className }, attrs),
331-
htmlLine,
332-
{ whitespace: TriviaRenderFlags.NoWhitespace }
333-
));
330+
htmlLines.push(
331+
span(mergeAttributes({ class: className }, attrs), htmlLine, { whitespace: TriviaRenderFlags.NoWhitespace })
332+
);
334333
}
335334

336335
const className = joinClassNames(wrapperClassName, joinThemeClassNames(themeClassNames), 'vscode-highlight');
337336
node.type = 'html';
338337
node.value = renderHTML(
339-
pre({ class: className, 'data-language': languageName }, [
340-
code({ class: 'vscode-highlight-code' }, htmlLines, { whitespace: TriviaRenderFlags.NewlineBetweenChildren })
341-
], { whitespace: TriviaRenderFlags.NoWhitespace })
338+
pre(
339+
{ class: className, 'data-language': languageName },
340+
[
341+
code({ class: 'vscode-highlight-code' }, htmlLines, {
342+
whitespace: TriviaRenderFlags.NewlineBetweenChildren
343+
})
344+
],
345+
{ whitespace: TriviaRenderFlags.NoWhitespace }
346+
)
342347
);
343348
} finally {
344349
unlockRegistry();
@@ -352,9 +357,9 @@ function createPlugin() {
352357
value: renderHTML(
353358
style({ class: 'vscode-highlight-styles' }, [
354359
injectStyles ? styles : '',
355-
...themeNames.map(theme => stylesheets[theme]),
360+
...themeNames.map(theme => stylesheets[theme])
356361
])
357-
),
362+
)
358363
});
359364
}
360365
}

src/renderUtils.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ function joinClassNames(...classNames) {
5353
}
5454

5555
/**
56-
* @param {string} tagName
57-
* @param {object} attributes
56+
* @param {string} tagName
57+
* @param {object} attributes
5858
* @param {(ElementTemplate | string)[]} children
5959
* @param {RenderOptions=} renderOptions
6060
* @returns {ElementTemplate}
@@ -88,11 +88,11 @@ const span = factory('span');
8888
const style = factory('style');
8989

9090
const TriviaRenderFlags = {
91-
NoWhitespace: 0,
92-
NewlineAfterOpeningTag: 1 << 0,
91+
NoWhitespace: 0,
92+
NewlineAfterOpeningTag: 1 << 0,
9393
NewlineBeforeClosingTag: 1 << 1,
94-
NewlineBetweenChildren: 1 << 2,
95-
IndentChildren: 1 << 3,
94+
NewlineBetweenChildren: 1 << 2,
95+
IndentChildren: 1 << 3
9696
};
9797

9898
/**
@@ -108,10 +108,11 @@ function renderHTML(element, indent = 0) {
108108
}
109109

110110
const { tagName, attributes, children } = element;
111-
const attrs = Object.keys(attributes).map(attr => ` ${attr}="${escape(attributes[attr])}"`).join('');
111+
const attrs = Object.keys(attributes)
112+
.map(attr => ` ${attr}="${escape(attributes[attr])}"`)
113+
.join('');
112114
let html = '';
113115

114-
115116
write(`<${tagName}${attrs}>`);
116117
if (whitespace & TriviaRenderFlags.NewlineAfterOpeningTag) {
117118
writeNewline();
@@ -158,5 +159,5 @@ module.exports = {
158159
code,
159160
span,
160161
style,
161-
TriviaRenderFlags,
162+
TriviaRenderFlags
162163
};

src/storeUtils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ async function ensureThemeLocation(themeNameOrId, themeCache, markdownFilePath)
4949
const theme = themes[themeId];
5050
if (themeNameOrId === themeId || themeNameOrId.toLowerCase() === theme.label.toLowerCase()) {
5151
const themePath = path.isAbsolute(theme.path) ? theme.path : path.resolve(__dirname, '../lib/themes', theme.path);
52-
if (!await exists(themePath)) {
52+
if (!(await exists(themePath))) {
5353
throw new Error(`Theme manifest lists '${themeNameOrId}' at '${themePath}, but no such file exists.'`);
5454
}
5555
}
5656
}
5757

5858
const locallyResolved = path.resolve(path.dirname(markdownFilePath), themeNameOrId);
59-
if (!await exists(locallyResolved)) {
60-
throw new Error(`Theme manifest does not contain theme '${themeNameOrId}', and no theme file exists at '${locallyResolved}'.`);
59+
if (!(await exists(locallyResolved))) {
60+
throw new Error(
61+
`Theme manifest does not contain theme '${themeNameOrId}', and no theme file exists at '${locallyResolved}'.`
62+
);
6163
}
6264
}
6365

0 commit comments

Comments
 (0)