-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathbinary_name.js
More file actions
57 lines (47 loc) · 1.64 KB
/
Copy pathbinary_name.js
File metadata and controls
57 lines (47 loc) · 1.64 KB
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
var path = require('path');
var Binary = function(options) {
var options = options || {};
var package_json = options.package_json || require('../package.json');
this.name = options.name || 'binding';
this.configuration = options.configuration || 'Release';
this.uri = options.uri || 'http://'+this.name+'.s3.amazonaws.com/';
this.module_maj_min = package_json.version.split('.').slice(0,2).join('.');
this.module_abi = package_json.abi;
this.platform = options.platform || process.platform;
this.target_arch = options.target_arch || process.arch;
if (process.versions.modules) {
this.node_abi = 'node-v' + process.versions.modules
} else {
this.node_abi = 'v8-' + process.versions.v8.split('.').slice(0,2).join('.');
}
}
Binary.prototype.filename = function() {
return this.name + '.node';
}
Binary.prototype.compression = function() {
return '.tar.gz';
}
Binary.prototype.getBasePath = function() {
return this.node_abi
+ '-' + this.platform
+ '-' + this.target_arch;
}
Binary.prototype.getRequirePath = function(configuration) {
return './' + path.join('binding',
configuration || this.configuration,
this.getBasePath(),
this.filename());
}
Binary.prototype.getModuleAbi = function() {
return this.name + '-v' + this.module_maj_min + '.' + this.module_abi;
}
Binary.prototype.getArchivePath = function() {
return this.getModuleAbi()
+ '-'
+ this.getBasePath()
+ this.compression();
}
Binary.prototype.getRemotePath = function() {
return this.uri+this.configuration+'/'+this.getArchivePath();
}
module.exports.Binary = Binary;