Skip to content

Commit

Permalink
chore(gatsby-plugin-page-creator): replace parse-filepath polyfill wi…
Browse files Browse the repository at this point in the history
…th native path.parse (#13122)
  • Loading branch information
paulmelnikow authored and wardpeet committed May 14, 2019
1 parent 6771f0f commit 2178756
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/gatsby-plugin-page-creator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"glob": "^7.1.1",
"lodash": "^4.17.10",
"micromatch": "^3.1.10",
"parse-filepath": "^1.0.1",
"slash": "^1.0.0"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/gatsby-plugin-page-creator/src/create-path.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// @flow
import parsePath from "parse-filepath"
import path from "path"

module.exports = (filePath: string): string => {
const { dirname, name } = parsePath(filePath)
const { dir, name } = path.parse(filePath)
const parsedName = name === `index` ? `` : name

return path.posix.join(`/`, dirname, parsedName, `/`)
return path.posix.join(`/`, dir, parsedName, `/`)
}
5 changes: 2 additions & 3 deletions www/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const _ = require(`lodash`)
const Promise = require(`bluebird`)
const path = require(`path`)
const parseFilepath = require(`parse-filepath`)
const fs = require(`fs-extra`)
const slash = require(`slash`)
const slugify = require(`slugify`)
Expand Down Expand Up @@ -594,7 +593,7 @@ exports.onCreateNode = ({ node, actions, getNode, reporter }) => {
const { createNodeField } = actions
let slug
if (node.internal.type === `File`) {
const parsedFilePath = parseFilepath(node.relativePath)
const parsedFilePath = path.parse(node.relativePath)
if (node.sourceInstanceName === `docs`) {
if (parsedFilePath.name !== `index` && parsedFilePath.dir !== ``) {
slug = `/${parsedFilePath.dir}/${parsedFilePath.name}/`
Expand All @@ -612,7 +611,7 @@ exports.onCreateNode = ({ node, actions, getNode, reporter }) => {
getNode(node.parent).internal.type === `File`
) {
const fileNode = getNode(node.parent)
const parsedFilePath = parseFilepath(fileNode.relativePath)
const parsedFilePath = path.parse(fileNode.relativePath)
// Add slugs for docs pages
if (fileNode.sourceInstanceName === `docs`) {
if (parsedFilePath.name !== `index` && parsedFilePath.dir !== ``) {
Expand Down
1 change: 0 additions & 1 deletion www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"lodash-es": "^4.17.11",
"mitt": "^1.1.3",
"mousetrap": "^1.6.1",
"parse-filepath": "^1.0.2",
"parse-github-url": "^1.0.2",
"prismjs": "^1.14.0",
"qs": "^6.5.2",
Expand Down

0 comments on commit 2178756

Please sign in to comment.