Skip to content

Commit

Permalink
Handle Windows paths when trying to resolve @node-red location
Browse files Browse the repository at this point in the history
Fixes #32
  • Loading branch information
knolleary committed Mar 25, 2019
1 parent b400840 commit d6695c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,16 @@ class NodeTestHelper extends EventEmitter {
} else {
if (!fs.existsSync(path.join(prefix, '@node-red/runtime/lib/nodes'))) {
// Not in the NR source tree, need to go hunting for the modules....
if (/node_modules\/node-red\/lib$/.test(prefix)) {
if (fs.existsSync(path.join(prefix,'..','node_modules','@node-red/runtime/lib/nodes'))) {
// path/to/node_modules/node-red/lib
// path/to/node_modules/node-red/node_modules/@node-red
prefix = path.resolve(path.join(prefix,"..","node_modules"));
} else if (fs.existsSync(path.join(prefix,'..','..','@node-red/runtime/lib/nodes'))) {
// path/to/node_modules/node-red/lib
// path/to/node_modules/@node-red
prefix = path.resolve(path.join(prefix,"..",".."));
} else {
throw new Error("Cannot find the NR source tree. Please raise an issue against node-red/node-red-node-test-helper with full details.");
throw new Error("Cannot find the NR source tree. Path: '"+prefix+"'. Please raise an issue against node-red/node-red-node-test-helper with full details.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-node-test-helper",
"version": "0.2.1",
"version": "0.2.2",
"description": "A test framework for Node-RED nodes",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d6695c2

Please sign in to comment.