Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/lib/dictionaryInfo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const rootUrl = new URL('../../', import.meta.url);
* Dictionary Package information.
* @typedef {object} DictionaryPackageInfo
* @property {string} name The name of the dictionary.
* @property {string} version The version of the package.
* @property {string} packageName The name of the package.
* @property {string} dir The directory containing the dictionary package.
* @property {boolean} cspell The dictionary package is bundled with cspell.
Expand Down Expand Up @@ -82,6 +83,7 @@ export async function fetchDictionaryInfo(dictURL) {
const hasEnabledByDefault = dictionaries.some((d) => d.enabled) || undefined;
return {
name: cspellExt.name || pkgJson.name,
version: pkgJson.version,
dir: path.relative(rootUrl.pathname, dictURL.pathname),
packageName: pkgJson.name,
description: cspellExt.description || pkgJson.description || '',
Expand Down
13 changes: 8 additions & 5 deletions scripts/lib/gen-dict-static-files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ function toCSpellSettings(pkgInfo, useCdn) {

const locales = [...new Set(pkgInfo.dictionaries.flatMap((d) => d.locales || []))].join(', ');
if (!pkgInfo.cspell) {
settings['import'] = [
(useCdn ? pkgNameToCdnUrl(pkgInfo.packageName) : pkgInfo.packageName) + '/cspell-ext.json',
];
const importPkg = useCdn
? new URL('cspell-ext.json', pkgNameToCdnUrl(pkgInfo.packageName, pkgInfo.version)).href
: pkgInfo.packageName + '/cspell-ext.json';
settings['import'] = [importPkg];
}
if (locales) {
settings['language'] = locales;
Expand All @@ -112,10 +113,12 @@ function toCSpellSettings(pkgInfo, useCdn) {
/**
*
* @param {string} pkgName
* @param {string} version
* @returns {string}
*/
function pkgNameToCdnUrl(pkgName) {
return `https://cdn.jsdelivr.net/npm/${pkgName}`;
function pkgNameToCdnUrl(pkgName, version) {
const v = version.split('.')[0] || '0';
return `https://cdn.jsdelivr.net/npm/${pkgName}@${v}/`;
}

/**
Expand Down
Loading