Passed
Push — master ( 55414e...5f39f4 )
by Björn
03:25
created

T_IMPORT   A

Complexity

Total Complexity 4
Complexity/F 4

Size

Lines of Code 1
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 1
ccs 1
cts 1
cp 1
rs 10
noi 0
c 1
b 0
f 0
cc 0
wmc 4
nc 1
mnd 2
bc 3
fnc 1
crap 0
bpm 3
cpm 4
1 1
import path from 'path';
2 1
import fs from 'fs';
3
4
function moduleOrProcessPath ( file_or_dir ) {
5
	
6 144
	var module     = path.join(__dirname, '../../'),
7 144
	    cwd        = process.cwd(),
8 144
	    relPath    = path.relative(cwd, module),
9
	    
10 144
	    cwdFile    = path.join(cwd, file_or_dir),
11 144
	    moduleFile = path.join(module, file_or_dir),
12 144
	    relFile    = path.join(relPath, file_or_dir);
13
	
14 144
	if ( (moduleFile != cwdFile) ) {
15 4
		if ( !fs.existsSync(cwdFile) && fs.existsSync(moduleFile)) {
16
			
17
			// dindn't find in 'project' dir but found in 'module' dir
18
			// so we actually have a relative path
19 1
			return (relFile);
20
			
21
		}
22
	}
23
24 143
	return (cwdFile);
25
	
26
}
27
28
module.exports = moduleOrProcessPath;