From 2178756e2043606fac62c0f03a5c20521127d758 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 14 May 2019 09:16:04 -0400 Subject: [PATCH] chore(gatsby-plugin-page-creator): replace parse-filepath polyfill with native path.parse (#13122) --- packages/gatsby-plugin-page-creator/package.json | 1 - packages/gatsby-plugin-page-creator/src/create-path.js | 5 ++--- www/gatsby-node.js | 5 ++--- www/package.json | 1 - 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/gatsby-plugin-page-creator/package.json b/packages/gatsby-plugin-page-creator/package.json index dcd0f99eac507..c0d0e0bd897ef 100644 --- a/packages/gatsby-plugin-page-creator/package.json +++ b/packages/gatsby-plugin-page-creator/package.json @@ -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": { diff --git a/packages/gatsby-plugin-page-creator/src/create-path.js b/packages/gatsby-plugin-page-creator/src/create-path.js index 26b2a217d7f18..d4edbf19a7b3a 100644 --- a/packages/gatsby-plugin-page-creator/src/create-path.js +++ b/packages/gatsby-plugin-page-creator/src/create-path.js @@ -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, `/`) } diff --git a/www/gatsby-node.js b/www/gatsby-node.js index b63458bcbe888..acf821df720bb 100644 --- a/www/gatsby-node.js +++ b/www/gatsby-node.js @@ -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`) @@ -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}/` @@ -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 !== ``) { diff --git a/www/package.json b/www/package.json index 57330634f3fbe..4a8db57eeb48d 100644 --- a/www/package.json +++ b/www/package.json @@ -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",