2020-09-21 01:14:06 -04:00
|
|
|
"use strict";
|
|
|
|
|
2020-09-22 22:54:48 -04:00
|
|
|
import fs from "fs";
|
2020-09-21 01:14:06 -04:00
|
|
|
|
2020-09-22 22:54:48 -04:00
|
|
|
import { colorify } from "../log";
|
|
|
|
import { resolve } from "../path";
|
2020-09-21 01:14:06 -04:00
|
|
|
|
|
|
|
const sourceEthers = fs.readFileSync(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-22 22:54:48 -04:00
|
|
|
console.log(colorify.bold(`Flattening exports...`))
|
|
|
|
|
2020-09-21 01:14:06 -04:00
|
|
|
fs.writeFileSync(resolve("packages/ethers/src.ts/index.ts"), output);
|