Passed
Push — master ( 50adea...d5902b )
by Amit
02:19
created

assets/build/util/assetManifestsFormatter.js   A

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 34
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 4
mnd 1
bc 4
fnc 2
bpm 2
cpm 2
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B assetManifestsFormatter.js ➔ ??? 0 32 2
1
const path = require('path');
2
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