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-cli): Convert ensure-windows-drive-letter-is-uppercase to typescript #22140

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
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
}