-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the babel-node error when there is no schema.json
- Loading branch information
Showing
3 changed files
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
module.exports = require('babel-relay-plugin')(require('../data/schema.json').data); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var jsonFile = path.join(__dirname, '../data/schema.json'); | ||
|
||
// Read the schema.json file only if it exists, this fixed | ||
// the problem of using babelRelayPlugin, defined in .babelrc, | ||
// and running npm run update when the file doesn't exist | ||
fs.access(jsonFile, fs.F_OK, function(err) { | ||
if (!err) module.exports = require('babel-relay-plugin')(require(jsonFile).data); | ||
}); | ||
|