Skip to content

Commit

Permalink
[bin] Recognize generated files in explicit artifact directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Feb 10, 2018
1 parent 2ab867b commit 7c36930
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/relay-compiler/bin/RelayCompilerBin.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async function run(options: {
validate: boolean,
quiet: boolean,
language: string,
artifactDirectory?: ?string,
artifactDirectory: ?string,
}) {
const schemaPath = path.resolve(process.cwd(), options.schema);
if (!fs.existsSync(schemaPath)) {
Expand Down Expand Up @@ -170,6 +170,13 @@ Ensure that one such file exists in ${srcDir} or its parents.
languagePlugin.findGraphQLTags,
);

const artifactDirectory = options.artifactDirectory
? // $FlowFixMe artifactDirectory can’t be null/undefined at this point
path.resolve(process.cwd(), options.artifactDirectory)
: null;

const isGeneratedDirectory = artifactDirectory || '__generated__';

const parserConfigs = {
js: {
baseDir: srcDir,
Expand Down Expand Up @@ -205,14 +212,10 @@ Ensure that one such file exists in ${srcDir} or its parents.
};
const writerConfigs = {
js: {
getWriter: getRelayFileWriter(
srcDir,
languagePlugin,
options.artifactDirectory,
),
getWriter: getRelayFileWriter(srcDir, languagePlugin, artifactDirectory),
isGeneratedFile: (filePath: string) =>
filePath.endsWith('.' + languagePlugin.outputExtension) &&
filePath.includes('__generated__'),
filePath.endsWith('.graphql.' + languagePlugin.outputExtension) &&
filePath.includes(isGeneratedDirectory),
parser: 'js',
baseParsers: ['graphql'],
},
Expand Down

0 comments on commit 7c36930

Please sign in to comment.