Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1603 from trufflesuite/windows-testresolver-impor…
Browse files Browse the repository at this point in the history
…t-path

allow test import paths to be OS-independent
  • Loading branch information
CruzMolina committed Jan 2, 2019
2 parents b2a61f5 + 83d13ff commit 935e91b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/truffle-core/lib/testing/testresolver.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require("path");

function TestResolver(resolver, source, search_path) {
this.resolver = resolver;
this.source = source;
Expand All @@ -13,6 +15,10 @@ TestResolver.prototype.require = function(import_path) {
return this.require_cache[import_path];
}

// For Windows: Allow import paths to be either path separator ('\' or '/')
// by converting all '/' to the default (path.sep);
import_path = import_path.replace(/\//g, path.sep);

// Remember: This throws if not found.
var result = this.resolver.require(import_path, this.search_path);

Expand All @@ -21,7 +27,11 @@ TestResolver.prototype.require = function(import_path) {
return result;
};

TestResolver.prototype.resolve = function(import_path, imported_from, callback) {
TestResolver.prototype.resolve = function(
import_path,
imported_from,
callback
) {
var self = this;
this.source.resolve(import_path, function(err, result, resolved_path) {
if (err) return callback(err);
Expand Down

0 comments on commit 935e91b

Please sign in to comment.