Skip to content

Commit b3372b1

Browse files
committed
Remove old dead code.
1 parent c473758 commit b3372b1

File tree

2 files changed

+16
-78
lines changed

2 files changed

+16
-78
lines changed

source/scripts/node/host/source/host.js

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,14 @@ const path = require('path');
66

77
/* Load MetaCall addon */
88
const addon = (() => {
9-
10-
const LIBRARY_PATH = process.env.LOADER_LIBRARY_PATH;
11-
12-
const folders = [
13-
path.join(__dirname, 'build'),
14-
__dirname,
15-
process.cwd(),
16-
LIBRARY_PATH,
17-
path.join(LIBRARY_PATH, 'build'),
18-
path.join(LIBRARY_PATH, 'node_modules', 'metacall'),
19-
path.join(LIBRARY_PATH, 'node_modules', 'metacall', 'build'),
20-
'/usr/local/lib',
21-
];
22-
23-
const names = [
24-
'node_loaderd',
25-
'node_loader',
26-
];
27-
28-
/* Load addon */
29-
return (() => {
30-
for (let folder of folders) {
31-
for (let name of names) {
32-
try {
33-
const location = path.join(folder, `${name}.node`);
34-
const port = require(location);
35-
36-
if (port) {
37-
console.log(`NodeJS Port found at location: ${location}`);
38-
return port;
39-
}
40-
} catch (e) {
41-
if (e.code !== 'MODULE_NOT_FOUND') {
42-
throw e;
43-
}
44-
}
45-
}
46-
}
47-
})();
9+
try {
10+
/* This forces metacall port to be run always by metacall cli */
11+
return process.binding('node_loader_port_module');
12+
} catch (e) {
13+
console.error('MetaCall failed to load, probably you are importing this file from NodeJS directly.');
14+
console.error('You should use MetaCall CLI instead. Install it from: https://github.com/metacall/install');
15+
throw e;
16+
}
4817
})();
4918

5019
const script = `#!/usr/bin/env python3

source/scripts/python/host/source/host.py.in

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,14 @@ const path = require('path');
1616
1717
/* Load MetaCall addon */
1818
const addon = (() => {
19-
20-
const LIBRARY_PATH = process.env.LOADER_LIBRARY_PATH;
21-
22-
const folders = [
23-
path.join(__dirname, 'build'),
24-
__dirname,
25-
process.cwd(),
26-
LIBRARY_PATH,
27-
path.join(LIBRARY_PATH, 'build'),
28-
path.join(LIBRARY_PATH, 'node_modules', 'metacall'),
29-
path.join(LIBRARY_PATH, 'node_modules', 'metacall', 'build'),
30-
'/usr/local/lib',
31-
];
32-
33-
const names = [
34-
'node_loaderd',
35-
'node_loader',
36-
];
37-
38-
/* Load addon */
39-
return (() => {
40-
for (let folder of folders) {
41-
for (let name of names) {
42-
try {
43-
const location = path.join(folder, `${name}.node`);
44-
const port = require(location);
45-
46-
if (port) {
47-
console.log(`NodeJS Port found at location: ${location}`);
48-
return port;
49-
}
50-
} catch (e) {
51-
if (e.code !== 'MODULE_NOT_FOUND') {
52-
throw e;
53-
}
54-
}
55-
}
56-
}
57-
})();
19+
try {
20+
/* This forces metacall port to be run always by metacall cli */
21+
return process.binding('node_loader_port_module');
22+
} catch (e) {
23+
console.error('MetaCall failed to load, probably you are importing this file from NodeJS directly.');
24+
console.error('You should use MetaCall CLI instead. Install it from: https://github.com/metacall/install');
25+
throw e;
26+
}
5827
})();
5928
6029
function b() {

0 commit comments

Comments
 (0)