Skip to content

Commit

Permalink
fix(gatsby-source-filesystem): Update createRemoteFileNode args (ga…
Browse files Browse the repository at this point in the history
…tsbyjs#35422)

* fixes issue gatsbyjs#35363 and CreateFileNodeFromBufferArgs

* modified tests for remote-file-node and file-node-from-buffer

* updated function calls in dependencies

* removed unused typescript imports

Co-authored-by: Ward Peeters <ward@coding-tech.com>
Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
  • Loading branch information
3 people committed Jun 1, 2022
1 parent 307a79c commit 64a01c7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 27 deletions.
13 changes: 5 additions & 8 deletions index.d.ts
@@ -1,4 +1,4 @@
import { Node, Store, NodePluginArgs } from "gatsby"
import { Node, GatsbyCache } from "gatsby"

/**
* @see https://www.gatsbyjs.com/plugins/gatsby-source-filesystem/?=files#createfilepath
Expand Down Expand Up @@ -28,9 +28,8 @@ export interface CreateFilePathArgs {

export interface CreateRemoteFileNodeArgs {
url: string
store: Store
// TODO: use GatsbyCache type (requires gatsby@2.22.13)
cache: NodePluginArgs["cache"]
cache?: GatsbyCache
getCache?: Function
createNode: Function
createNodeId: Function
parentNodeId?: string
Expand All @@ -41,14 +40,12 @@ export interface CreateRemoteFileNodeArgs {
httpHeaders?: object
ext?: string
name?: string
reporter: object
}

export interface CreateFileNodeFromBufferArgs {
buffer: Buffer
store: Store
// TODO: use GatsbyCache type (requires gatsby@2.22.13)
cache: NodePluginArgs["cache"]
cache?: GatsbyCache
getCache?: Function
createNode: Function
createNodeId: Function
parentNodeId?: string
Expand Down
9 changes: 0 additions & 9 deletions src/__tests__/create-file-node-from-buffer.js
Expand Up @@ -40,15 +40,6 @@ const bufferEq = (b1, b2) => Buffer.compare(b1, b2) === 0

describe(`create-file-node-from-buffer`, () => {
const defaultArgs = {
store: {
getState: jest.fn(() => {
return {
program: {
directory: `__whatever__`,
},
}
}),
},
createNode: jest.fn(),
createNodeId: jest.fn(),
}
Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/create-remote-file-node.js
@@ -1,7 +1,5 @@
import { fetchRemoteFile } from "gatsby-core-utils/fetch-remote-file"

const reporter = {}

const createRemoteFileNode = require(`../create-remote-file-node`)

jest.mock(`gatsby-core-utils/fetch-remote-file`, () => {
Expand Down Expand Up @@ -33,11 +31,9 @@ describe(`create-remote-file-node`, () => {

const defaultArgs = {
url: `https://external.com/dog.jpg`,
store: {},
getCache: () => cache,
createNode: jest.fn(),
createNodeId: jest.fn(() => String(uuid++)),
reporter,
ext: `.jpg`,
name: `dog-thumbnail`,
}
Expand Down
6 changes: 0 additions & 6 deletions src/create-remote-file-node.js
Expand Up @@ -11,11 +11,6 @@ const { createFileNode } = require(`./create-file-node`)
* @see gatsby/packages/gatsby/utils/cache.js
*/

/**
* @typedef {Reporter}
* @see gatsby/packages/gatsby-cli/lib/reporter.js
*/

/**
* @typedef {Auth}
* @type {Object}
Expand All @@ -33,7 +28,6 @@ const { createFileNode } = require(`./create-file-node`)
* @param {Function} options.createNode
* @param {Function} options.getCache
* @param {Auth} [options.auth]
* @param {Reporter} [options.reporter]
*/

/******************
Expand Down

0 comments on commit 64a01c7

Please sign in to comment.