forked from OKEAMAH/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
44 lines (37 loc) · 913 Bytes
/
util.js
File metadata and controls
44 lines (37 loc) · 913 Bytes
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
44
'use strict';
var fs = require('fs');
var path = require('path');
var root = path.resolve(__dirname, '..');
var tests = path.resolve(root, 'fixtures');
function stat(path) {
try {
return fs.statSync(path);
} catch (e) {
// Ignore ENOENT.
if (e.code !== 'ENOENT') {
throw e;
}
}
}
function testExists(testname) {
var s = stat(path.resolve(tests, testname));
return s && s.isDirectory();
}
function rewriteTestFile(testname, testfile) {
if (testfile.search(/^https?:\/\//) === 0) {
return testfile;
}
var i = 0;
while (testfile[i] === '/') ++i;
testfile = testfile.slice(i);
var s = stat(path.resolve(tests, testname, testfile));
if (s && (s.isFile() || s.isDirectory())) {
return ['/test/e2e/fixtures', testname, testfile].join('/');
}
return false;
}
module.exports = {
stat: stat,
testExists: testExists,
rewriteTestFile: rewriteTestFile
};