Skip to content

Commit 2178756

Browse files
paulmelnikowwardpeet
authored andcommitted
chore(gatsby-plugin-page-creator): replace parse-filepath polyfill with native path.parse (#13122)
1 parent 6771f0f commit 2178756

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

packages/gatsby-plugin-page-creator/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"glob": "^7.1.1",
2727
"lodash": "^4.17.10",
2828
"micromatch": "^3.1.10",
29-
"parse-filepath": "^1.0.1",
3029
"slash": "^1.0.0"
3130
},
3231
"devDependencies": {
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// @flow
2-
import parsePath from "parse-filepath"
32
import path from "path"
43

54
module.exports = (filePath: string): string => {
6-
const { dirname, name } = parsePath(filePath)
5+
const { dir, name } = path.parse(filePath)
76
const parsedName = name === `index` ? `` : name
87

9-
return path.posix.join(`/`, dirname, parsedName, `/`)
8+
return path.posix.join(`/`, dir, parsedName, `/`)
109
}

www/gatsby-node.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const _ = require(`lodash`)
22
const Promise = require(`bluebird`)
33
const path = require(`path`)
4-
const parseFilepath = require(`parse-filepath`)
54
const fs = require(`fs-extra`)
65
const slash = require(`slash`)
76
const slugify = require(`slugify`)
@@ -594,7 +593,7 @@ exports.onCreateNode = ({ node, actions, getNode, reporter }) => {
594593
const { createNodeField } = actions
595594
let slug
596595
if (node.internal.type === `File`) {
597-
const parsedFilePath = parseFilepath(node.relativePath)
596+
const parsedFilePath = path.parse(node.relativePath)
598597
if (node.sourceInstanceName === `docs`) {
599598
if (parsedFilePath.name !== `index` && parsedFilePath.dir !== ``) {
600599
slug = `/${parsedFilePath.dir}/${parsedFilePath.name}/`
@@ -612,7 +611,7 @@ exports.onCreateNode = ({ node, actions, getNode, reporter }) => {
612611
getNode(node.parent).internal.type === `File`
613612
) {
614613
const fileNode = getNode(node.parent)
615-
const parsedFilePath = parseFilepath(fileNode.relativePath)
614+
const parsedFilePath = path.parse(fileNode.relativePath)
616615
// Add slugs for docs pages
617616
if (fileNode.sourceInstanceName === `docs`) {
618617
if (parsedFilePath.name !== `index` && parsedFilePath.dir !== ``) {

www/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"lodash-es": "^4.17.11",
6161
"mitt": "^1.1.3",
6262
"mousetrap": "^1.6.1",
63-
"parse-filepath": "^1.0.2",
6463
"parse-github-url": "^1.0.2",
6564
"prismjs": "^1.14.0",
6665
"qs": "^6.5.2",

0 commit comments

Comments
 (0)