Skip to content

Commit

Permalink
0.0.3 - pass npm_config_argv for target build, such as nwjs
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Oct 9, 2016
1 parent ff8bcab commit 2bb825b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
// https://github.com/mapbox/node-sqlite3#building-for-sqlcipher
'use strict'
require('shelljs/global')
var isArray = require('util').isArray

var args
try {
args = JSON.parse(process.env.npm_config_argv).original
} finally {
if (!isArray(args)) {
args = []
}
}
var targetArgs = args.filter(function (arg) {
return /^--(runtime|target)/.test(arg)
})
var targetStr = targetArgs.reduce(function (m, arg) {
return m + ' ' + arg
}, '')

// not windows
if (process.platform === 'darwin') {
Expand All @@ -15,11 +31,11 @@ if (process.platform === 'darwin') {
}
exec('export LDFLAGS="-L`brew --prefix`/opt/sqlcipher/lib"')
exec('export CPPFLAGS="-I`brew --prefix`/opt/sqlcipher/include"')
exec('npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix`')
exec('npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix`' + targetStr)
} else {
// linux
exec('export LDFLAGS="-L/usr/local/lib"')
exec('export CPPFLAGS="-I/usr/local/include -I/usr/local/include/sqlcipher"')
exec('export CXXFLAGS="$CPPFLAGS"')
exec('npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/local --verbose')
exec('npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/local --verbose' + targetStr)
}

0 comments on commit 2bb825b

Please sign in to comment.