| Conditions | 2 |
| Paths | 2 |
| Total Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | const path = require('path'); |
||
| 3 | module.exports = (key, value) => { |
||
| 4 | if (typeof value === 'string') { |
||
| 5 | return value; |
||
| 6 | } |
||
| 7 | const manifest = value; |
||
| 8 | /** |
||
| 9 | * Hack to prepend scripts/ or styles/ to manifest keys |
||
| 10 | * |
||
| 11 | * This might need to be reworked at some point. |
||
| 12 | * |
||
| 13 | * Before: |
||
| 14 | * { |
||
| 15 | * "main.js": "scripts/main_abcdef.js" |
||
| 16 | * "main.css": "styles/main_abcdef.css" |
||
| 17 | * } |
||
| 18 | * After: |
||
| 19 | * { |
||
| 20 | * "scripts/main.js": "scripts/main_abcdef.js" |
||
| 21 | * "styles/main.css": "styles/main_abcdef.css" |
||
| 22 | * } |
||
| 23 | */ |
||
| 24 | Object.keys(manifest).forEach((src) => { |
||
| 25 | const sourcePath = path.basename(path.dirname(src)); |
||
| 26 | const targetPath = path.basename(path.dirname(manifest[src])); |
||
| 27 | if (sourcePath === targetPath) { |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | manifest[`${targetPath}/${src}`] = manifest[src]; |
||
| 31 | delete manifest[src]; |
||
| 32 | }); |
||
| 33 | return manifest; |
||
| 34 | }; |
||
| 35 |