Skip to content

Commit 1b20a5c

Browse files
committed
fix Doesn't work on Mac #9
1 parent a837123 commit 1b20a5c

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"scripts": {
2727
"configure": "node-gyp configure",
2828
"build": "node-gyp configure build --jobs max",
29-
"postinstall": "install_name_tool -change @rpath/libDynamsoftBarcodeReader.dylib @loader_path/libDynamsoftBarcodeReader.dylib build/Release/dbr.node",
29+
"postinstall": "node ./scripts/postinstall.js",
3030
"clean": "node-gyp clean"
3131
},
3232
"gypfile": true

scripts/postinstall.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var exec = require('child_process').exec;
2+
var os = require('os');
3+
4+
function puts(error, stdout, stderr) { console.error(error) }
5+
6+
const commands_linux = []
7+
8+
const commands_darwin = [
9+
"install_name_tool -change @rpath/libDynamsoftBarcodeReader.dylib @loader_path/libDynamsoftBarcodeReader.dylib build/Release/dbr.node"
10+
]
11+
12+
const commands_windows = []
13+
14+
// Run command depending on the OS
15+
if (os.type() === 'Linux') {
16+
if(commands_linux.length > 0) exec(commands_linux.join('&&'), puts);
17+
} else if (os.type() === 'Darwin') {
18+
if(commands_darwin.length > 0) exec(commands_darwin.join('&&'), puts);
19+
} else if (os.type() === 'Windows_NT') {
20+
if(commands_windows.length > 0) exec(commands_windows.join('&&'), puts);
21+
}
22+

0 commit comments

Comments
 (0)