OpenAsar/scripts/injectPolyfills.js

18 lines
487 B
JavaScript
Raw Normal View History

2021-12-11 00:45:56 +00:00
const { readdirSync, mkdirSync, copyFileSync } = require('fs');
const { join } = require('path');
const rootDir = join(__dirname, '..');
const polyfillsDir = join(rootDir, 'polyfills');
2021-12-11 00:45:56 +00:00
for (const file of readdirSync(polyfillsDir)) {
const [ name ] = file.split('.');
const jsPath = join(polyfillsDir, file);
const moduleDir = join(rootDir, 'src', 'node_modules', name);
2021-12-11 00:45:56 +00:00
try {
mkdirSync(moduleDir);
} catch (e) {}
copyFileSync(jsPath, join(moduleDir, 'index.js'));
}