[Scripts > InjectPolyfill] Ensure node_modules exists

This commit is contained in:
Ducko 2022-01-14 14:04:36 +00:00
parent b3ffacf472
commit 11248d1455

View file

@ -1,12 +1,14 @@
const { readdirSync, copyFileSync } = require('fs');
const { readdirSync, copyFileSync, mkdirSync } = require('fs');
const { join } = require('path');
const rootDir = join(__dirname, '..');
const nodeModules = join(rootDir, 'src', 'node_modules');
mkdirSync(nodeModules, { recursive: true }); // Ensure node_modules exists
const polyfillsDir = join(rootDir, 'polyfills');
for (const file of readdirSync(polyfillsDir)) {
const [ name ] = file.split('.');
const jsPath = join(polyfillsDir, file);
copyFileSync(jsPath, join(rootDir, 'src', 'node_modules', name + '.js'));
copyFileSync(jsPath, join(nodeModules, name + '.js'));
}