stylelint
Version:
A mighty CSS linter that helps you avoid errors and enforce conventions.
24 lines (22 loc) • 515 B
JavaScript
import { fileURLToPath } from 'node:url';
/**
* Converts a URL to a file path string, or returns the string as-is.
*
* @overload
* @param {string | URL} cwd
* @returns {string}
*
* @overload
* @param {undefined} cwd
* @returns {undefined}
*
* @overload
* @param {string | URL | undefined} cwd
* @returns {string | undefined}
*
* @param {string | URL | undefined} cwd
* @returns {string | undefined}
*/
export default function toPath(cwd) {
return cwd instanceof URL ? fileURLToPath(cwd) : cwd;
}