From e031fbee31b3f412691d1d93e538c5f3342b035c Mon Sep 17 00:00:00 2001 From: Yuki Takemoto Date: Wed, 11 Mar 2020 01:02:24 +0900 Subject: [PATCH] chore(gatsby-cli): Convert ensure-windows-drive-letter-is-uppercase to typescript (#22140) --- packages/gatsby-cli/src/index.ts | 4 ++-- ....js => ensure-windows-drive-letter-is-uppercase.ts} | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename packages/gatsby-cli/src/util/{ensure-windows-drive-letter-is-uppercase.js => ensure-windows-drive-letter-is-uppercase.ts} (88%) diff --git a/packages/gatsby-cli/src/index.ts b/packages/gatsby-cli/src/index.ts index 3af5eea71459c..e218297a33611 100755 --- a/packages/gatsby-cli/src/index.ts +++ b/packages/gatsby-cli/src/index.ts @@ -8,7 +8,7 @@ import createCli from "./create-cli" import report from "./reporter" import pkg from "../package.json" import updateNotifier from "update-notifier" -import ensureWindowsDriveLetterIsUppercase from "./util/ensure-windows-drive-letter-is-uppercase" +import { ensureWindowsDriveLetterIsUppercase } from "./util/ensure-windows-drive-letter-is-uppercase" const useJsonLogger = process.argv.slice(2).some(arg => arg.includes(`json`)) @@ -39,7 +39,7 @@ if (!semver.satisfies(process.version, `>=${MIN_NODE_VERSION}`)) { if (!semver.satisfies(process.version, `>=${NEXT_MIN_NODE_VERSION}`)) { report.warn( report.stripIndent(` - Node.js ${process.version} has reached End of Life status on 31 December, 2019. + Node.js ${process.version} has reached End of Life status on 31 December, 2019. Gatsby will only actively support ${NEXT_MIN_NODE_VERSION} or higher and drop support for Node 8 soon. Please upgrade Node.js to a currently active LTS release: https://gatsby.dev/upgrading-node-js `) diff --git a/packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.js b/packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.ts similarity index 88% rename from packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.js rename to packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.ts index 8f94bea8e3d48..0615b95931c35 100644 --- a/packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.js +++ b/packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.ts @@ -1,5 +1,5 @@ -const { tmpdir } = require(`os`) -const report = require(`../reporter`) +import { tmpdir } from "os" +import report from "../reporter" /** * This function ensures that the current working directory on Windows @@ -20,7 +20,7 @@ const report = require(`../reporter`) * and then the next one from "C:" shell, you may get a bunch of webpack warnings * because it expects module paths to be case-sensitive. */ -module.exports = function ensureWindowsDriveLetterIsUppercase() { +export function ensureWindowsDriveLetterIsUppercase(): void { const cwd = process.cwd() const normalizedCwd = driveLetterToUpperCase(cwd) @@ -51,9 +51,9 @@ module.exports = function ensureWindowsDriveLetterIsUppercase() { } } -function driveLetterToUpperCase(path) { +function driveLetterToUpperCase(path: string): string { const segments = path.split(`:\\`) return segments.length > 1 - ? segments.shift().toUpperCase() + `:\\` + segments.join(`:\\`) + ? segments.shift()!.toUpperCase() + `:\\` + segments.join(`:\\`) : path }