Browse files

Fixing relative file requires.

  • Loading branch information...
1 parent 4dcd0e3 commit b367dbd9ff7a881579f64fc427a32865240a3d01 @keithpitt committed Apr 27, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/jest/runner.js
View
16 lib/jest/runner.js
@@ -38,19 +38,31 @@ function Runner(options) {
} catch(e) {}
}
- if(!data || !p) {
+ if(!p) {
console.log("Could not find file `" + file + "` in the following paths:");
console.log(localPaths);
process.exit(1);
}
+ if(!data) {
+ console.log("No data found in `" + p + "`");
+ process.exit(1);
+ }
+
+ var actualFoundFile = p;
+
var prepared = data.replace(/(#|\/\/)\=\s*require\s*(.+)/g, function() {
var p = RegExp.$2;
// Prepand the real path if it starts with a ./
if(p.match(/\.\//)) {
- p = path.join(path.dirname(fs.realpathSync(file)), p);
+ try {
+ p = path.join(path.dirname(fs.realpathSync(actualFoundFile)), p);
+ } catch(e) {
+ console.log("Could not find file `" + p + "`");
+ process.exit(1);
+ }
}
unparsed.push(p);

0 comments on commit b367dbd

Please sign in to comment.