Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix path on Windows #4544

Closed
wants to merge 11 commits into from
20 changes: 15 additions & 5 deletions packages/babel-plugin-relay/compileGraphQLTag.js
Expand Up @@ -29,6 +29,14 @@ const {

const GENERATED = './__generated__/';

/**
* Converts backslashes in a path to forward slashes (POSIX style) for
* cross-platform compatibility.
*/
function posixifyPath(path: string): string {
return process.platform === 'win32' ? path.replace(/\\/g, '/') : path;
}

/**
* Given a graphql`` tagged template literal, replace it with the appropriate
* runtime artifact.
Expand Down Expand Up @@ -107,11 +115,13 @@ function createNode(
throw new Error('GraphQL operations and fragments must contain names');
}
const requiredFile = definitionName + '.graphql';
const requiredPath = options.isHasteMode
? requiredFile
: options.artifactDirectory
? getRelativeImportPath(state, options.artifactDirectory, requiredFile)
: GENERATED + requiredFile;
const requiredPath = posixifyPath(
options.isHasteMode
? requiredFile
: options.artifactDirectory
? getRelativeImportPath(state, options.artifactDirectory, requiredFile)
: GENERATED + requiredFile,
);

const hash = crypto
.createHash('md5')
Expand Down