Skip to content

Instantly share code, notes, and snippets.

@tubackkhoa
Created January 25, 2024 09:13
Show Gist options
  • Save tubackkhoa/72079fedebe5ef98eaeed7ed261134d0 to your computer and use it in GitHub Desktop.
Save tubackkhoa/72079fedebe5ef98eaeed7ed261134d0 to your computer and use it in GitHub Desktop.
import
const glob = require('glob');
const util = require('util');
const globPromise = util.promisify(glob);
const importArr = [];
const exportArr = ['export default {'];
const paths = [
'node_modules/@tharsis/proto/dist/proto/evmos/**/*.js',
'node_modules/@tharsis/proto/dist/proto/ethermint/**/*.js',
];
(async () => {
let ind = 100;
for (const importPath of paths) {
const files = await globPromise(importPath);
for (const file of files) {
exportArr.push(`\t..._${ind},`);
importArr.push(
`import * as _${ind} from '${file
.replace(/^node_modules\//, '')
.replace(/\.js$/, '')}';`
);
ind++;
}
}
exportArr.push('}');
// ..._137,
console.log(importArr.join('\n'));
console.log(exportArr.join('\n'));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment