Skip to content

Commit a5ecd97

Browse files
ksmythdefunctzombie
authored andcommitted
Add node-pre-gyp support for prebuilt binaries (#278)
1 parent 6191bb9 commit a5ecd97

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

appveyor.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
environment:
2+
matrix:
3+
- nodejs_version: "0.10"
4+
platform: x64
5+
- nodejs_version: "0.10"
6+
platform: x86
7+
- nodejs_version: "0.12"
8+
platform: x64
9+
- nodejs_version: "0.12"
10+
platform: x86
11+
- nodejs_version: "4"
12+
platform: x64
13+
- nodejs_version: "4"
14+
platform: x86
15+
- nodejs_version: "5"
16+
platform: x64
17+
- nodejs_version: "5"
18+
platform: x86
19+
- nodejs_version: "6"
20+
platform: x64
21+
- nodejs_version: "6"
22+
platform: x86
23+
24+
install:
25+
- where npm
26+
- where node
27+
- ps: Install-Product node $env:nodejs_version $env:platform
28+
- for /f "delims=" %%a in ('where npm') do cd %%a\.. && npm install npm@latest
29+
- for /f "delims=" %%a in ('where npm') do cd %%a\.. && npm install node-pre-gyp@latest
30+
- 'if "%nodejs_version%_%platform%" == "4_x86" (npm config set -g cafile=package.json && npm config set -g strict-ssl=false)'
31+
32+
build: off
33+
34+
artifacts:
35+
- path: 'build/stage/**/bcrypt*.tar.gz'
36+
- path: package.json
37+
38+
test_script:
39+
- node --version
40+
- npm --version
41+
- npm test
42+
43+
after_test:
44+
- node-pre-gyp package

bcrypt.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
'use strict';
22

3-
var bindings = require('bindings')('bcrypt_lib');
3+
var binary = require('node-pre-gyp');
4+
var path = require('path');
5+
var binding_path = binary.find(path.resolve(path.join(__dirname, './package.json')));
6+
var bindings = require(binding_path);
7+
48
var crypto = require('crypto');
59

610
/// generate a salt (sync)

binding.gyp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717
],
1818
}],
1919
],
20+
},
21+
{
22+
"target_name": "action_after_build",
23+
"type": "none",
24+
"dependencies": [ "<(module_name)" ],
25+
"copies": [
26+
{
27+
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
28+
"destination": "<(module_path)"
29+
}
30+
]
2031
}
2132
]
2233
}

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
"url": "https://github.com/ncb000gt/node.bcrypt.js/issues"
2626
},
2727
"scripts": {
28-
"test": "node-gyp configure build && nodeunit test"
28+
"test": "npm install --build-from-source && nodeunit test",
29+
"install": "node-pre-gyp install --fallback-to-build"
2930
},
3031
"dependencies": {
3132
"bindings": "1.2.1",
32-
"nan": "2.3.5"
33+
"nan": "2.3.5",
34+
"node-pre-gyp": "0.6.30"
3335
},
3436
"devDependencies": {
3537
"nodeunit": "~0.9.1"
@@ -49,5 +51,11 @@
4951
"Nate Rajlich <[email protected]> (https://github.com/tootallnate)",
5052
"Sean McArthur <[email protected]> (https://github.com/seanmonstar)",
5153
"Fanie Oosthuysen <[email protected]> (https://github.com/weareu)"
52-
]
54+
],
55+
"binary": {
56+
"module_name": "bcrypt_lib",
57+
"module_path": "./lib/binding/",
58+
"host": "https://github.com",
59+
"remote_path": "/ncb000gt/node.bcrypt.js/releases/download/v{version}/"
60+
}
5361
}

0 commit comments

Comments
 (0)