MCPcopy
hub / github.com/vitejs/vite / checkBadCharactersInPath

Function checkBadCharactersInPath

packages/vite/src/node/config.ts:1053–1083  ·  view source on GitHub ↗

* Check and warn if `path` includes characters that don't work well in Vite, * such as `#` and `?` and `*`.

(
  name: string,
  type: 'directory' | 'file',
  path: string,
  logger: Logger,
)

Source from the content-addressed store, hash-verified

1051 * such as `#` and `?` and `*`.
1052 */
1053function checkBadCharactersInPath(
1054 name: string,
1055 type: 'directory' | 'file',
1056 path: string,
1057 logger: Logger,
1058): void {
1059 const badChars = []
1060
1061 if (path.includes('#')) {
1062 badChars.push('#')
1063 }
1064 if (path.includes('?')) {
1065 badChars.push('?')
1066 }
1067 if (path.includes('*')) {
1068 badChars.push('*')
1069 }
1070
1071 if (badChars.length > 0) {
1072 const charString = badChars.map((c) => `"${c}"`).join(' and ')
1073 const inflectedChars = badChars.length > 1 ? 'characters' : 'character'
1074
1075 logger.warn(
1076 colors.yellow(
1077 `${name} contains the ${charString} ${inflectedChars} (${colors.cyan(
1078 path,
1079 )}), which may not work when running Vite. Consider renaming the ${type} without the characters.`,
1080 ),
1081 )
1082 }
1083}
1084
1085const clientAlias = [
1086 {

Callers 2

resolveConfigFunction · 0.85
loadConfigFromFileFunction · 0.85

Calls 1

warnMethod · 0.65

Tested by

no test coverage detected