[Scripts > InjectPolyfill] Ensure node_modules exists
This commit is contained in:
parent
b3ffacf472
commit
11248d1455
|
@ -1,12 +1,14 @@
|
||||||
const { readdirSync, copyFileSync } = require('fs');
|
const { readdirSync, copyFileSync, mkdirSync } = require('fs');
|
||||||
const { join } = require('path');
|
const { join } = require('path');
|
||||||
|
|
||||||
const rootDir = join(__dirname, '..');
|
const rootDir = join(__dirname, '..');
|
||||||
|
const nodeModules = join(rootDir, 'src', 'node_modules');
|
||||||
|
mkdirSync(nodeModules, { recursive: true }); // Ensure node_modules exists
|
||||||
|
|
||||||
const polyfillsDir = join(rootDir, 'polyfills');
|
const polyfillsDir = join(rootDir, 'polyfills');
|
||||||
for (const file of readdirSync(polyfillsDir)) {
|
for (const file of readdirSync(polyfillsDir)) {
|
||||||
const [ name ] = file.split('.');
|
const [ name ] = file.split('.');
|
||||||
const jsPath = join(polyfillsDir, file);
|
const jsPath = join(polyfillsDir, file);
|
||||||
|
|
||||||
copyFileSync(jsPath, join(rootDir, 'src', 'node_modules', name + '.js'));
|
copyFileSync(jsPath, join(nodeModules, name + '.js'));
|
||||||
}
|
}
|
Loading…
Reference in New Issue