1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2025-11-23 21:34:49 +02:00

Use import.meta.dirname & import.meta.filename (#10863)

This commit is contained in:
LitoMore
2025-05-27 19:22:37 +08:00
committed by GitHub
parent ca73753ea3
commit cd1934aaf3
15 changed files with 64 additions and 151 deletions

View File

@@ -8,17 +8,14 @@
/**
* @typedef {import("../sdk.js").IconData} IconData
*/
import fs from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';
import {checkbox, confirm, input, search} from '@inquirer/prompts';
import chalk from 'chalk';
import {search as fuzzySearch} from 'fast-fuzzy';
import getRelativeLuminance from 'get-relative-luminance';
import {
getIconsDataString,
normalizeColor,
titleToSlug,
urlRegex,
} from '../sdk.mjs';
import {getIconsDataString, normalizeColor, titleToSlug} from '../sdk.mjs';
import {
formatIconData,
getJsonSchemaData,
@@ -54,6 +51,20 @@ const licenseTypes = [
...spdxLicenseIds.map((id) => ({name: id, value: id})),
];
/**
* Build a regex to validate HTTPs URLs.
* @returns {Promise<RegExp>} Regex to validate HTTPs URLs.
*/
const urlRegex = async () =>
new RegExp(
JSON.parse(
await fs.readFile(
path.resolve(import.meta.dirname, '..', '.jsonschema.json'),
'utf8',
),
).definitions.url.pattern,
);
/**
* Whether an input is a valid URL.
* @param {string} input URL input.