-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathgetabi.js
59 lines (47 loc) · 1.98 KB
/
getabi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
////////////////////////////////////////////////////////////////////////////////
// -------------------------------------------------------------------------- //
// //
// (C) 2010-2018 Robot Developers //
// See LICENSE for licensing info //
// //
// -------------------------------------------------------------------------- //
////////////////////////////////////////////////////////////////////////////////
"use strict";
//----------------------------------------------------------------------------//
// Requires //
//----------------------------------------------------------------------------//
var mFS = require ("fs" );
var mPath = require ("path");
//----------------------------------------------------------------------------//
// Main //
//----------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////////
/// Discovers the Node ABI version by peeking into the node_version header file
/// Expects the header include path as an argument and works with Node and IOjs
var paths =
[
mPath.join (process.argv[2], "include", "node", "node_version.h"),
mPath.join (process.argv[2], "src", "node_version.h")
];
var contents = null;
// Iterate through all possible paths
for (var i = 0; i < paths.length; ++i)
{
try
{
// Read the contents of the header file
contents = mFS.readFileSync (paths[i]);
break;
} catch (e) { }
}
// Verify read
if (!contents)
{
console.error ("Unable to find node_version.h");
process.exitCode = 1;
}
else
{
console.info (contents.toString().match
(/\s+NODE_MODULE_VERSION\s+(\d+)/)[1]);
}