Skip to content

Commit

Permalink
fix: No md files found on Windows (closes #7) (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
icaraps authored Jan 15, 2021
1 parent f33b298 commit cce6e08
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ exports.createSchemaCustomization = ({ actions }) => {
}

exports.sourceNodes = async ({ actions, createNodeId, createContentDigest }, options = {}) => {
const cwd = process.cwd()
const root = options.root ? options.root : ''
const { paths: pages = ['src/pages'], extensions = ['md', 'mdx'] } = options.pages ? options.pages : {}
const { token, owner, name, branch = 'main', default_branch = 'main' } = options.repo ? options.repo : {}
Expand All @@ -38,7 +39,9 @@ exports.sourceNodes = async ({ actions, createNodeId, createContentDigest }, opt
console.warn('To get Github Contributors, a Github token is required (GITHUB_TOKEN environment variable)')
}

const paths = await globby(pages.map(page => path.resolve(process.cwd(), page)), {
// Support Windows
const regExp = /\\/g
const paths = await globby(pages.map(page => path.resolve(cwd, page).replace(regExp, '//')), {
expandDirectories: {
extensions
}
Expand All @@ -59,7 +62,7 @@ exports.sourceNodes = async ({ actions, createNodeId, createContentDigest }, opt
})

for (const _path of paths) {
let githubPath = path.join(root, _path.replace(process.cwd(), ''))
let githubPath = path.join(root, _path.replace(cwd, ''))
if (githubPath.charAt(0) === path.sep) githubPath = githubPath.substr(1)

let contributors = []
Expand Down

0 comments on commit cce6e08

Please sign in to comment.