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): Convert get-static-dir to typescript #22083

Merged
merged 4 commits into from
Mar 9, 2020
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
2 changes: 2 additions & 0 deletions packages/gatsby/src/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface IReduxState {
pageData: any
pages: any
babelrc: any
themes: any
flattenedPlugins: any
}

export interface ICachedReduxState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const fs = require(`fs-extra`)
const chokidar = require(`chokidar`)
const nodePath = require(`path`)
const { store } = require(`../redux`)
import fs from "fs-extra"
import chokidar from "chokidar"
import nodePath from "path"
import { store } from "../redux"

/**
* copyStaticDirs
* --
* Copy files from the static directory to the public directory
*/
exports.copyStaticDirs = () => {
export const copyStaticDirs = (): void => {
// access the store to get themes
const { themes, flattenedPlugins } = store.getState()
// if there are legacy themes, only use them. Otherwise proceed with plugins
Expand All @@ -30,7 +30,7 @@ exports.copyStaticDirs = () => {
.map(folder => fs.copySync(folder, nodePath.join(process.cwd(), `public`)))

const staticDir = nodePath.join(process.cwd(), `static`)
if (!fs.existsSync(staticDir)) return Promise.resolve()
if (!fs.existsSync(staticDir)) return undefined
return fs.copySync(staticDir, nodePath.join(process.cwd(), `public`), {
dereference: true,
})
Expand All @@ -41,7 +41,7 @@ exports.copyStaticDirs = () => {
* --
* Set up a watcher to sync changes from the static directory to the public directory
*/
exports.syncStaticDir = () => {
export const syncStaticDir = (): void => {
const staticDir = nodePath.join(process.cwd(), `static`)
chokidar
.watch(staticDir)
Expand Down