diff --git a/packages/gatsby/src/utils/node-manifest.ts b/packages/gatsby/src/utils/node-manifest.ts index d21651a73c3f1..61ed87b5aba9b 100644 --- a/packages/gatsby/src/utils/node-manifest.ts +++ b/packages/gatsby/src/utils/node-manifest.ts @@ -249,19 +249,26 @@ export async function processNodeManifest( ) /** - * Commas are considered special characters on Windows and are not valid in file paths with the exception of - * the hard disk partition name at the beginning of a file path (i.e. C:). + * Windows has a handful of special/reserved characters that are not valid in a file path + * @reference https://superuser.com/questions/358855/what-characters-are-safe-in-cross-platform-file-names-for-linux-windows-and-os + * + * The one exception is the comma that is part of the hard disk partition name at the beginning of a file path (i.e. C:). * * During local development, node manifests can be written to disk but are generally unused as they are only used - * for Content Sync which runs in Gatsby cloud. Gatsby cloud is a Linux environment in which colons are valid in - * filepaths. To avoid errors on Windows, we replace all ":" instances in the filepath (with the exception of the + * for Content Sync which runs in Gatsby Cloud. Gatsby cloud is a Linux environment in which these special chars are valid in + * filepaths. To avoid errors on Windows, we replace all instances of the special chars in the filepath (with the exception of the * hard disk partition name) with "-" to ensure that local Windows development setups do not break when attempting * to write one of these manifests to disk. */ if (process.platform === `win32`) { - manifestFilePath = manifestFilePath.replace(/(?|\|/g, + `-` + ) } + console.log(`manifest file path: ${manifestFilePath}`) + const manifestFileDir = path.dirname(manifestFilePath) await fs.ensureDir(manifestFileDir)