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): migrate test-require-error to typescript #22265

Merged
merged 4 commits into from
Mar 19, 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
5 changes: 3 additions & 2 deletions packages/gatsby/src/bootstrap/get-config-file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @flow */
const levenshtein = require(`fast-levenshtein`)
const fs = require(`fs-extra`)
const testRequireError = require(`../utils/test-require-error`).default
import { testRequireError } from "../utils/test-require-error"
const report = require(`gatsby-cli/lib/reporter`)
const path = require(`path`)
const existsSync = require(`fs-exists-cached`).sync
Expand All @@ -20,7 +20,8 @@ module.exports = async function getConfigFile(
distance: number = 3
) {
const configPath = path.join(rootDir, configName)
let configModule, configFilePath
let configModule
let configFilePath
try {
configFilePath = require.resolve(configPath)
configModule = require(configFilePath)
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/bootstrap/resolve-module-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { codeFrameColumns } = require(`@babel/code-frame`)
const { babelParseToAst } = require(`../utils/babel-parse-to-ast`)
const report = require(`gatsby-cli/lib/reporter`)

const testRequireError = require(`../utils/test-require-error`).default
import { testRequireError } from "../utils/test-require-error"

const staticallyAnalyzeExports = (modulePath, resolver = require.resolve) => {
let absPath
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const testRequireError = require(`../test-require-error`).default
import { testRequireError } from "../test-require-error"

describe(`test-require-error`, () => {
it(`detects require errors`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This module is also copied into the .cache directory some modules copied there
// from cache-dir can also use this module.
export default (moduleName, err) => {
export const testRequireError = (moduleName: string, err: any): boolean => {
// PnP will return the following code when a require is allowed per the
// dependency tree rules but the requested file doesn't exist
if (
Expand Down