Skip to content

Instantly share code, notes, and snippets.

@kaychaks
Last active January 18, 2020 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaychaks/9f7a83b0e982cf4c76b69de165c5da1f to your computer and use it in GitHub Desktop.
Save kaychaks/9f7a83b0e982cf4c76b69de165c5da1f to your computer and use it in GitHub Desktop.
"scripts": {
"relay": "node scripts/relayCompiler.js"
},
//scripts/relayCompiler.js
const spawn = require("child_process").spawn;
const path = require("path");
const args = [
"--extensions",
"js",
"jsx",
"--schema",
path.resolve(__dirname, "../schema/schema.graphql"),
"--src",
path.resolve(__dirname, ".."), // since we are currently in <rootDir>/scripts
"--include", // these will be based off of the `--src` flag ☝️
"src/**",
"node_modules/@foundation/logger/src/**",
"--exclude",
"**/__mocks__/**",
"**/__tests__/**",
"**/__generated__/**",
"--artifactDirectory",
"src/__generated__/relay"
];
if (process.argv.includes("--watch")) {
args.push("--watch");
}
if (process.argv.includes("--no-watchman")) {
args.push("--no-watchman");
}
const proc = spawn(
path.resolve(__dirname, "../node_modules/.bin/relay-compiler"),
args,
{ stdio: "inherit" }
);
proc.on("close", code => {
process.exit(code);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment