Skip to content

Commit

Permalink
chore(gatsby): Migrate redirects-writer to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
PerfectPan committed Apr 21, 2020
1 parent fae27a8 commit 777fa4a
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import _ from "lodash"
import crypto from "crypto"
import fs from "fs-extra"
import { store, emitter } from "../redux/"
import { store, emitter } from "../redux"
import { joinPath } from "gatsby-core-utils"

let lastHash = null
let lastHash: string | null = null
let bootstrapFinished = false

const writeRedirects = async () => {
export const writeRedirects = async (): Promise<void> => {
bootstrapFinished = true

let { program, redirects } = store.getState()
const { program, redirects } = store.getState()

// Filter for redirects that are meant for the browser.
const browserRedirects = redirects.filter(r => r.redirectInBrowser)
Expand All @@ -31,9 +32,6 @@ const writeRedirects = async () => {
)
}

exports.writeRedirects = writeRedirects

let bootstrapFinished = false
let oldRedirects
const debouncedWriteRedirects = _.debounce(() => {
// Don't write redirects again until bootstrap has finished.
Expand Down

0 comments on commit 777fa4a

Please sign in to comment.