-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdelete-libs.js
45 lines (35 loc) · 1.33 KB
/
delete-libs.js
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
var path = require('path');
var fs = require('fs');
var glob = require('glob');
const fse = require('fs-extra');
var bundleFilePaths = glob.sync('/packages/**/bundle.js', {root: path.join(__dirname)});
const libPath = path.join(__dirname, '/libraries/');
bundleFilePaths.forEach(bundlePath => {
let fileContent = fs.readFileSync(bundlePath, 'utf8');
let modifed = false;
const Oskari = {
clazz: {
define: (id, constructor, methods, metadata) => {
if (!metadata.source) {
return;
}
if (metadata.source.scripts) {
metadata.source.scripts
.map(script => path.join(path.dirname(bundlePath), script.src))
.filter(path => {
return path.indexOf('oskari-frontend-contrib/libraries/') >= 0
})
.forEach(p => {
if (fs.existsSync(p)) {
fse.moveSync(p, path.join(__dirname, 'saved' , p.substring(libPath.length)));
}
});
}
}
},
bundle_manager: {
installBundleClass: function (id, path) { }
}
}
eval(fileContent);
});