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

Search in cmake-build-debug and cmake-build-release for CLion convenience #64

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ function requireNativeModule(name, debug) {
// Suffixes to search for (in each mode)
// Both are used, debug just changes which is tried first
var search = {
debug: path.join('build', 'Debug', name + '.node'),
release: path.join('build', 'Release', name + '.node')
debug: [
path.join('build', 'Debug', name + '.node'),
path.join('cmake-build-debug', name + '.node')
],
release: [
path.join('build', 'Release', name + '.node'),
path.join('cmake-build-release', name + '.node')
]
};

var root = base;
Expand All @@ -22,14 +28,38 @@ function requireNativeModule(name, debug) {
// Walk upward to the root of the current drive
while(same < 2 || found) {
try {
location = path.join(root, (debug) ? search.debug : search.release);
found = fs.statSync(location);
const paths = (debug) ? search.debug : search.release;
for(const p of paths)
{
location = path.join(root, p);
found = false;
try {
found = fs.statSync(location);
}
catch(e){}
if (found)
{
break;
}
}
}
catch(e) {}
if(!found) {
try {
location = path.join(root, (debug) ? search.release : search.debug);
found = fs.statSync(location);
const paths = (debug) ? search.release : search.debug;
for(const p of paths)
{
location = path.join(root, p);
found = false;
try {
found = fs.statSync(location);
}
catch(e){}
if (found)
{
break;
}
}
}
catch(e) {}
}
Expand Down