diff --git a/.gitignore b/.gitignore index 3c3629e647f5ddf82548912e337bea9826b434af..a4e6641c3002f58f29ee3c9b86ed8f36aa03fca7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +.DS_Store node_modules +config.json diff --git a/cli.js b/cli.js index b71489efd718fca6971bad72e0ed8b2d4d581a1b..241df4563ad5abd3cf585b28626187d19966c7fc 100644 --- a/cli.js +++ b/cli.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + var Lock = require('./lib/lock'); var noble = require('noble'); @@ -7,7 +9,6 @@ var argv = require('yargs') .usage('Control an August Smart Lock.\nUsage: $0 [command]') .example('$0 lock', 'closes the lock') .example('$0 unlock', 'opens the lock') - .describe('config', 'configuration file (default is $HOME/.config/augustctl.json)') .check(function(argv) { if (argv._.length !== 1) { return 'must specify an operation to perform'; @@ -20,7 +21,7 @@ var argv = require('yargs') }) .argv; -var config = require('./config')(argv.config); +var config = require(process.env.AUGUSTCTL_CONFIG || './config.json'); noble.on('stateChange', function(state) { if (state === 'poweredOn') { diff --git a/config.js b/config.js deleted file mode 100644 index b47ba72834b26e09970332f9ed1e7537d258e19a..0000000000000000000000000000000000000000 --- a/config.js +++ /dev/null @@ -1,17 +0,0 @@ -var fs = require('fs'); - -function loadConfig(filename) { - if (!filename) { - var configDir = process.env.XDG_CONFIG_HOME || (process.env.HOME + '/.config'); - filename = configDir + '/augustctl.json'; - } - - var config = JSON.parse(fs.readFileSync(filename)); - if (!config.offlineKey || !config.offlineKeyOffset) { - throw new Error("config file must specify offlineKey and offlineKeyOffset"); - } - - return config; -} - -module.exports = loadConfig; diff --git a/tools/decode_capture.js b/tools/decode_capture.js index 150d20b5b712029c07b57e7b5af1a0d95fdf63f6..391e5da6e6378e157268ed1febe4dbb3ab01e4ce 100644 --- a/tools/decode_capture.js +++ b/tools/decode_capture.js @@ -73,5 +73,5 @@ function decodeLog(offlineKey, filename) { }); } -var config = require('../config')(); +var config = require(process.env.AUGUSTCTL_CONFIG || '../config.json'); decodeLog(config.offlineKey, process.argv[2]);