UNPKG

@shopify/theme-language-server-common

Version:

<h1 align="center" style="position: relative;" > <br> <img src="https://github.com/Shopify/theme-check-vscode/blob/main/images/shopify_glyph.png?raw=true" alt="logo" width="141" height="160"> <br> Theme Language Server </h1>

40 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.makeRunChecks = void 0; const theme_check_common_1 = require("@shopify/theme-check-common"); function makeRunChecks(documentManager, diagnosticsManager, { fs, loadConfig, themeDocset, jsonValidationSet, }) { return async function runChecks(triggerURIs) { // This function takes an array of triggerURIs so that we can correctly // recheck on file renames that came from out of bounds in a // workspaces. // // e.g. if a user renames // theme1/snippets/a.liquid to // theme1/snippets/b.liquid // // then we recheck theme1 const fileExists = (0, theme_check_common_1.makeFileExists)(fs); const rootURIs = await Promise.all(triggerURIs.map((uri) => (0, theme_check_common_1.findRoot)(uri, fileExists))); const deduplicatedRootURIs = new Set(rootURIs); await Promise.all([...deduplicatedRootURIs].map(runChecksForRoot)); return; async function runChecksForRoot(configFileRootUri) { const config = await loadConfig(configFileRootUri, fs); const theme = documentManager.theme(config.rootUri); const offenses = await (0, theme_check_common_1.check)(theme, config, { jsonValidationSet, themeDocset, fs, }); // We iterate over the theme files (as opposed to offenses) because if // there were offenses before, we need to send an empty array to clear // them. for (const sourceCode of theme) { const sourceCodeOffenses = offenses.filter((offense) => offense.uri === sourceCode.uri); diagnosticsManager.set(sourceCode.uri, sourceCode.version, sourceCodeOffenses); } } }; } exports.makeRunChecks = makeRunChecks; //# sourceMappingURL=runChecks.js.map