-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpromote-node-modules-to-server.js
More file actions
executable file
·46 lines (40 loc) · 1.44 KB
/
Copy pathpromote-node-modules-to-server.js
File metadata and controls
executable file
·46 lines (40 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const fs = require('fs');
const fsExtra = require('fs-extra');
console.log('Running promote-node-modules-to-server.js');
console.log('clearing lib directory');
fsExtra.emptyDirSync('enable-node-libs');
// we must copy the needed node modules into the lib directory
const nodeFiles = [
'node_modules/indent.js/lib/indent.min.js',
'node_modules/glider-js/glider.js',
'node_modules/glider-js/glider.css',
'node_modules/text-zoom-event/dist/textZoomEvent.module.js',
'node_modules/dialog-polyfill/index.js',
'node_modules/jquery/dist/jquery.min.js',
'node_modules/jquery-validation/dist/jquery.validate.min.js',
'node_modules/accessibility-js-routines/dist/accessibility.module.js',
'node_modules/wicg-inert/dist/inert.min.js',
'node_modules/js-cookie/dist/js.cookie.js'
];
nodeFiles.forEach((fullPath) => {
const explodedPath = fullPath.split('/');
let fileName = explodedPath.pop();
let dir = explodedPath
.join('/')
.replace(/^node_modules\//, 'enable-node-libs/');
console.log('dir', dir);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, {
recursive: true,
});
}
const newPath = `${dir}/${fileName}`;
console.log(`Copying node module ${fullPath} to ${newPath}.`);
fs.copyFile(fullPath, newPath, (err) => {
if (err) {
throw err;
} else {
console.log(`${fullPath} was copied to ${newPath}`);
}
});
});