From f273b48e7377cfd9923b1c9530ee140a37cc5f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Levy?= Date: Wed, 20 Sep 2023 13:59:57 +0000 Subject: [PATCH] fix: add GEOTMPDIR env (#258) * fix: support tmp dir overwrite with env var * docs: env vars chapter --- README.md | 12 ++++++++++++ scripts/updatedb.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 45cfa31e..d3744d74 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,18 @@ geoip.startWatchingDataUpdate(); This tool can be used with `npm run-script updatedb` to periodically update geo data on a running server. +#### Environment variables + +The following environment variables can be set. + +```bash +# Override the default node_modules/geoip-lite/data dir +GEOTMPDIR=/some/path + +# Override the default node_modules/geoip-lite/tmp dir +GEODATADIR=/some/path +``` + Caveats ------- diff --git a/scripts/updatedb.js b/scripts/updatedb.js index 662c466b..8e59ac1f 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -44,7 +44,7 @@ if (typeof geodatadir !== 'undefined') { process.exit(1); } } -var tmpPath = path.resolve(__dirname, '..', 'tmp'); +var tmpPath = process.env.GEOTMPDIR ? process.env.GEOTMPDIR : path.resolve(__dirname, '..', 'tmp'); var countryLookup = {}; var cityLookup = {}; var databases = [