Skip to content

Commit e031fbe

Browse files
authoredMar 10, 2020
chore(gatsby-cli): Convert ensure-windows-drive-letter-is-uppercase to typescript (#22140)
1 parent dc4e21e commit e031fbe

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed
 

‎packages/gatsby-cli/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import createCli from "./create-cli"
88
import report from "./reporter"
99
import pkg from "../package.json"
1010
import updateNotifier from "update-notifier"
11-
import ensureWindowsDriveLetterIsUppercase from "./util/ensure-windows-drive-letter-is-uppercase"
11+
import { ensureWindowsDriveLetterIsUppercase } from "./util/ensure-windows-drive-letter-is-uppercase"
1212

1313
const useJsonLogger = process.argv.slice(2).some(arg => arg.includes(`json`))
1414

@@ -39,7 +39,7 @@ if (!semver.satisfies(process.version, `>=${MIN_NODE_VERSION}`)) {
3939
if (!semver.satisfies(process.version, `>=${NEXT_MIN_NODE_VERSION}`)) {
4040
report.warn(
4141
report.stripIndent(`
42-
Node.js ${process.version} has reached End of Life status on 31 December, 2019.
42+
Node.js ${process.version} has reached End of Life status on 31 December, 2019.
4343
Gatsby will only actively support ${NEXT_MIN_NODE_VERSION} or higher and drop support for Node 8 soon.
4444
Please upgrade Node.js to a currently active LTS release: https://gatsby.dev/upgrading-node-js
4545
`)

‎packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.js ‎packages/gatsby-cli/src/util/ensure-windows-drive-letter-is-uppercase.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { tmpdir } = require(`os`)
2-
const report = require(`../reporter`)
1+
import { tmpdir } from "os"
2+
import report from "../reporter"
33

44
/**
55
* This function ensures that the current working directory on Windows
@@ -20,7 +20,7 @@ const report = require(`../reporter`)
2020
* and then the next one from "C:" shell, you may get a bunch of webpack warnings
2121
* because it expects module paths to be case-sensitive.
2222
*/
23-
module.exports = function ensureWindowsDriveLetterIsUppercase() {
23+
export function ensureWindowsDriveLetterIsUppercase(): void {
2424
const cwd = process.cwd()
2525
const normalizedCwd = driveLetterToUpperCase(cwd)
2626

@@ -51,9 +51,9 @@ module.exports = function ensureWindowsDriveLetterIsUppercase() {
5151
}
5252
}
5353

54-
function driveLetterToUpperCase(path) {
54+
function driveLetterToUpperCase(path: string): string {
5555
const segments = path.split(`:\\`)
5656
return segments.length > 1
57-
? segments.shift().toUpperCase() + `:\\` + segments.join(`:\\`)
57+
? segments.shift()!.toUpperCase() + `:\\` + segments.join(`:\\`)
5858
: path
5959
}

0 commit comments

Comments
 (0)
Please sign in to comment.