Skip to content

Commit

Permalink
Use normalize-path so tests pass on windows (#2908)
Browse files Browse the repository at this point in the history
* Use normalize-path so tests pass on windows

* Format

* Fix last test

* Almost got them all...
  • Loading branch information
KyleAMathews authored Nov 13, 2017
1 parent 3267d6e commit 6cd114f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/gatsby-remark-code-repls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"babel-runtime": "^6.26.0",
"lz-string": "^1.4.4",
"normalize-path": "^2.1.1",
"recursive-readdir-synchronous": "^0.0.3",
"unist-util-map": "^1.0.3"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby-remark-code-repls/src/constants.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict"

const { join } = require(`path`)
const normalizePath = require(`normalize-path`)

module.exports = {
OPTION_DEFAULT_LINK_TEXT: `REPL`,
OPTION_DEFAULT_REDIRECT_TEMPLATE_PATH: join(
__dirname,
`default-redirect-template.js`
OPTION_DEFAULT_REDIRECT_TEMPLATE_PATH: normalizePath(
join(__dirname, `default-redirect-template.js`)
),
PROTOCOL_BABEL: `babel://`,
PROTOCOL_CODEPEN: `codepen://`,
Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby-remark-code-repls/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const fs = require(`fs`)
const { extname, resolve } = require(`path`)
const recursiveReaddir = require(`recursive-readdir-synchronous`)
const normalizePath = require(`normalize-path`)

const {
OPTION_DEFAULT_LINK_TEXT,
Expand Down Expand Up @@ -65,7 +66,8 @@ exports.createPages = (

createPage({
path: slug,
component: resolve(redirectTemplate),
// Normalize the path so tests pass on Linux + Windows
component: normalizePath(resolve(redirectTemplate)),
context: {
action,
payload,
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby-remark-code-repls/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require(`fs`)
const LZString = require(`lz-string`)
const { join } = require(`path`)
const map = require(`unist-util-map`)
const normalizePath = require(`normalize-path`)

const {
OPTION_DEFAULT_LINK_TEXT,
Expand Down Expand Up @@ -48,7 +49,7 @@ module.exports = (
if (!filePath.endsWith(`.js`)) {
filePath += `.js`
}
filePath = join(directory, filePath)
filePath = normalizePath(join(directory, filePath))
return filePath
}

Expand Down

0 comments on commit 6cd114f

Please sign in to comment.