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

Commit

Permalink
[fix] allow asset importers to define which content they can load
Browse files Browse the repository at this point in the history
  • Loading branch information
Yacine Badiss committed Jan 21, 2022
1 parent 97d487f commit 80d8b7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions script/crypto-assets-importer/importers/ethereum-plugins.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require("path");
const fs = require('fs');
const isEqual = require("lodash/isEqual");
const { readFileJSON } = require("../utils");

Expand Down Expand Up @@ -34,6 +35,11 @@ module.exports = {

outputTemplate: (data) => JSON.stringify(data, null, 2),

shouldLoad: ({ folder, id }) => {
const b2cFilePath = path.join(folder, id, "b2c.json");
return fs.existsSync(b2cFilePath);
},

loader: async ({ signatureFolder, folder, id }) => {
const [signatures, bare] = await Promise.all([
readFileJSON(path.join(signatureFolder, id, "b2c_signatures.json")),
Expand Down
3 changes: 2 additions & 1 deletion script/crypto-assets-importer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ axios
const folder = path.join(inputFolder, "assets", p);
const signatureFolder = path.join(inputFolder, "signatures/prod/", p);
const items = fs.readdirSync(folder);
const shouldLoad = ((id) => imp.shouldLoad ? imp.shouldLoad({ folder, id }) : !id.endsWith(".json"));
return promiseAllBatched(
50,
items.sort().filter((a) => !a.endsWith(".json")),
items.sort().filter(shouldLoad),
(id) =>
Promise.resolve()
.then(() => imp.loader({ signatureFolder, folder, id }))
Expand Down

0 comments on commit 80d8b7b

Please sign in to comment.