From 7a2df5a6a11da11ce044b2ff553ee7348263a686 Mon Sep 17 00:00:00 2001 From: Ali Lokhandwala Date: Thu, 23 Feb 2017 10:58:47 +0000 Subject: [PATCH 1/3] Fix path to build.js, other npm install fails. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f4f9cc8..d531f26 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Fast offline coarse Geocoder", "main": "./lib/index.js", "bin": { - "geocoder.js": "build.js" + "geocoder.js": "./data/build.js" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 72499c5533e6734538a02116507c37b2fee4dba3 Mon Sep 17 00:00:00 2001 From: Ali Lokhandwala Date: Fri, 24 Feb 2017 10:14:12 +0000 Subject: [PATCH 2/3] Fix readme. geocoder is a different module to geocoder.js --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ad0ffd..54b367d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Fast offline coarse Geocoder based on GeoNames data. ## Usage ```js -var geocoder = require('geocoder'); +var geocoder = require('geocoder.js'); geocoder('Big Apple', function (location) { /* From 2d4b31f8c14c6d310f9c029e84bae6b63d8c635c Mon Sep 17 00:00:00 2001 From: Ali Lokhandwala Date: Fri, 24 Feb 2017 10:15:09 +0000 Subject: [PATCH 3/3] Allow the geonames db to be specified as an environment variable. GEONAMES_SQLITE_DB --- lib/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 0b0bd21..0c5f302 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,9 +1,16 @@ 'use strict'; var _ = require('lodash'), - db = require('dblite').withSQLite('3.8.6+')(__dirname + '/../data/geonames.db', '-header'), + dblite = require('dblite').withSQLite('3.8.6+'), async = require('async'); +var db; +if (process.env.GEONAMES_SQLITE_DB) { + db = dblite(process.env.GEONAMES_SQLITE_DB, '-header'); +} else { + db = dblite(__dirname + '/../data/geonames.db', '-header'); +} + db.on('close', function (code) { if (code !== 0) { console.error(code);