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

[fix] allow asset importers to define which content they can load #772

Merged
merged 1 commit into from
Jan 31, 2022
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
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