Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getPackagePlugins() {
const rootDir = path.resolve(__dirname, '..');
const docSections = fs.readdirSync(`${rootDir}/docs/`).filter(dir => {
const fullDir = path.join(`${rootDir}/docs/`, dir);
return fs.existsSync(fullDir) && fs.lstatSync(fullDir).isDirectory();
});
const workspaces = await getWorkspaces({ cwd: rootDir });
return [
...docSections.map(name => ({
resolve: 'gatsby-source-filesystem',
options: { name, path: `${rootDir}/docs/${name}/` },
})),
...workspaces
.filter(({ config }) => !config.private)
.filter(({ dir }) => fs.existsSync(dir))
.filter(({ dir }) => !dir.includes('arch'))
.map(({ dir, config }) => ({
resolve: 'gatsby-source-filesystem',
options: {
// This `name` will show up as `sourceInstanceName` on a node's "parent"
// See `gatsby-node.js` for where it's used.
name: config.name,