Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
fix: avoid array.prototype.flat (#15)
Browse files Browse the repository at this point in the history
Update tsconfig to reflect that we are using ES2018 (Node 10). Array.prototype.flat is only available in Node 11. Instead of using a polyfill, we will use concat to flatten the array of object arrays
  • Loading branch information
robinmetral authored Mar 4, 2020
1 parent 9638294 commit 585dd97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ export async function sourceNodes(
};

try {
const objects = await Promise.all(
let objects: Array<any> = await Promise.all(
buckets.map(bucket => listObjects(bucket))
);
// flatten objects
// flat() is not supported in node 10
objects = [].concat(...objects);

// create file nodes
// todo touch nodes if they exist already
objects?.flat().forEach(async object => {
objects?.forEach(async object => {
const { Key, Bucket } = object;
const { region } = awsConfig;

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"lib": ["ES2018"],
"module": "CommonJS",
// support node 10 and newer
"target": "ES2018",
Expand Down

0 comments on commit 585dd97

Please sign in to comment.