You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
704 B

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*/
const request = require('request-promise');
const errorCodesUrl =
'https://raw.githubusercontent.com/facebook/react/main/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);
}
};