Files
react.dev/plugins/gatsby-source-react-error-codes/gatsby-node.js
Michał Gołębiowski-Owczarek 06a8850b2f HTTPS-ify lots of URLs, update some to their newer homes (#1157)
This matters for user security.

I didn't touch blog posts & pages related to past conferences.

The `content/docs` could be HTTPS-ified as well but it contains lots of HTTP
links so maybe that'd be best done in a separate PR.
2018-10-05 14:39:12 -07:00

31 lines
661 B
JavaScript

const request = require('request-promise');
const errorCodesUrl =
'https://raw.githubusercontent.com/facebook/react/master/scripts/error-codes/codes.json';
exports.sourceNodes = async ({actions}) => {
const {createNode} = actions;
try {
const jsonString = await request(errorCodesUrl);
createNode({
id: 'error-codes',
children: [],
parent: 'ERRORS',
internal: {
type: 'ErrorCodesJson',
contentDigest: jsonString,
},
});
} catch (error) {
console.error(
`The gatsby-source-react-error-codes plugin has failed:\n${
error.message
}`,
);
process.exit(1);
}
};