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
Changes from 1 commit
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
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 | Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you look into what it would take to make this always return Promise and what impacts that would have on any consuming functions? I don't like the difference in return types here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of returning Promise.resolve, he can just return

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MichaelDeBoey!
I return undefined instead of Promise.resolve to pass consistent-return rule.

// access the store to get themes
const { themes, flattenedPlugins } = store.getState()
// if there are legacy themes, only use them. Otherwise proceed with plugins
Expand Down Expand Up @@ -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