Skip to content

Commit

Permalink
chore(gatsby-cli): Convert ensure-windows-drive-letter-is-uppercase t…
Browse files Browse the repository at this point in the history
…o typescript (#22140)
  • Loading branch information
mottox2 authored Mar 10, 2020
1 parent dc4e21e commit e031fbe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`))

Expand Down Expand Up @@ -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
`)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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
}

0 comments on commit e031fbe

Please sign in to comment.