Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gatsby-core-utils): path to ts #22054

Merged
merged 3 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { joinPath, isNodeInternalModulePath, slash } = require(`../path`)
const os = require(`os`)
import { joinPath, isNodeInternalModulePath, slash } from "../path"
import os from "os"

describe(`paths`, () => {
describe(`joinPath`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const path = require(`path`)
const os = require(`os`)
import path from "path"
import os from "os"

/**
* @type {import('../index').joinPath}
*/
export function joinPath(...paths) {
export function joinPath(...paths: string[]): string {
const joinedPath = path.join(...paths)
if (os.platform() === `win32`) {
return joinedPath.replace(/\\/g, `\\\\`)
Expand Down Expand Up @@ -72,7 +72,7 @@ const nodePaths = [
/**
* @type {import('../index').isNodeInternalModulePath}
*/
export const isNodeInternalModulePath = fileName =>
export const isNodeInternalModulePath = (fileName: string): boolean =>
nodePaths.some(regTest => regTest.test(fileName))

/**
Expand All @@ -84,7 +84,7 @@ export const isNodeInternalModulePath = fileName =>
* @param {String} path
* @return {String} slashed path
*/
export function slash(path) {
export function slash(path: string): string {
const isExtendedLengthPath = /^\\\\\?\\/.test(path)

if (isExtendedLengthPath) {
Expand Down