-
-
Notifications
You must be signed in to change notification settings - Fork 608
/
Copy pathgetExecutedCode.js
31 lines (26 loc) · 1010 Bytes
/
getExecutedCode.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
import { execute, readAsset } from "./index";
export default (asset, compiler, stats, type) => {
let executed = execute(readAsset(asset, compiler, stats), type);
if (Array.isArray(executed)) {
executed = executed.map((module) => {
if (module[0] && typeof module[0].replace === "function") {
// eslint-disable-next-line no-param-reassign
module[0] = module[0].replace(/!\.\/=!/g, "!=!");
// eslint-disable-next-line no-param-reassign
module[0] = module[0].replace(/\.\/(.+)!=!/g, "$1!=!");
}
return module;
});
}
if (executed && typeof executed.text !== "undefined") {
executed.text = executed.text.replace(/file:\/\/\/[a-z]:\//gi, "file:///");
} else if (Array.isArray(executed)) {
executed.forEach((item) => {
if (typeof item.text !== "undefined") {
// eslint-disable-next-line no-param-reassign
item.text = item.text.replace(/file:\/\/\/[a-z]:\//gi, "file:///");
}
});
}
return executed;
};