| 1 |
"use strict"; |
| 2 |
|
| 3 |
var path = require("path") |
| 4 |
, findRoot = require("next/module/find-package-root"); |
| 5 |
|
| 6 |
var resolve = path.resolve, sep = path.sep; |
| 7 |
|
| 8 |
module.exports = function (tpath) { |
| 9 |
return findRoot(tpath)(function (projectPath) { |
| 10 |
var e; |
| 11 |
tpath = tpath.slice(projectPath.length + 1).split(sep); |
| 12 |
if (tpath[0] === "test") { |
| 13 |
e = new Error("Input seems to be a test file"); |
| 14 |
e.type = "testfile"; |
| 15 |
throw e; |
| 16 |
} |
| 17 |
return resolve(projectPath, "test" + sep + tpath.join(sep)); |
| 18 |
}); |
| 19 |
}; |