mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-12 21:38:32 +03:00
comment es5/es6 import in lib/blueprinters
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
const REL_PATH_TO_BPS = "../blueprinters";
|
|
||||||
const allBps = {};
|
|
||||||
|
|
||||||
export const defaultBlueprint = {
|
export const defaultBlueprint = {
|
||||||
name: null,
|
name: null,
|
||||||
id: null,
|
id: null,
|
||||||
@@ -19,13 +16,18 @@ export const defaultRoute = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// import all default exports from 'blueprinters' folder
|
// import all default exports from 'blueprinters' folder
|
||||||
|
const allBps = {};
|
||||||
|
const REL_PATH_TO_BPS = "../blueprinters";
|
||||||
const normalizedPath = path.join(__dirname, REL_PATH_TO_BPS);
|
const normalizedPath = path.join(__dirname, REL_PATH_TO_BPS);
|
||||||
fs.readdirSync(normalizedPath).forEach(file => {
|
fs.readdirSync(normalizedPath).forEach(file => {
|
||||||
const bpName = file.replace(".js", "");
|
const bpName = file.replace(".js", "");
|
||||||
allBps[bpName] = require(`${REL_PATH_TO_BPS}/${file}`).default;
|
allBps[bpName] = require(`${REL_PATH_TO_BPS}/${file}`).default;
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = Object.assign({
|
// NB: revert to ES5 'module.exports' required to make blueprinters from
|
||||||
"defaultBlueprint": defaultBlueprint,
|
// each file in blueprinters folder available for granular import from here.
|
||||||
"defaultRoute": defaultRoute
|
module.exports = {
|
||||||
}, allBps);
|
defaultBlueprint,
|
||||||
|
defaultRoute,
|
||||||
|
...allBps
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user