ethers.js/misc/admin/lib/cmds/update-exports.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

"use strict";
2020-09-23 05:54:48 +03:00
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const log_1 = require("../log");
const path_1 = require("../path");
2021-10-16 09:29:27 +03:00
const sourceEthers = fs_1.default.readFileSync((0, path_1.resolve)("packages/ethers/src.ts/ethers.ts")).toString();
const targets = sourceEthers.match(/export\s*{\s*((.|\s)*)}/)[1].trim();
////////////////////
// Begin template
////////////////////
const output = `"use strict";
// To modify this file, you must update ./misc/admin/lib/cmds/update-exports.js
import * as ethers from "./ethers";
try {
const anyGlobal = (window as any);
if (anyGlobal._ethers == null) {
anyGlobal._ethers = ethers;
}
} catch (error) { }
export { ethers };
export {
${targets}
} from "./ethers";
`;
////////////////////
// End template
////////////////////
2020-09-23 05:54:48 +03:00
console.log(log_1.colorify.bold(`Flattening exports...`));
2021-10-16 09:29:27 +03:00
fs_1.default.writeFileSync((0, path_1.resolve)("packages/ethers/src.ts/index.ts"), output);