From b16de26cf930fc842287b2a745e32975f85a1d55 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Wed, 8 May 2019 23:18:21 +0200 Subject: [PATCH] fix(cli): fix config path (#3636) --- cli/api.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/api.js b/cli/api.js index 590a571a..ad76ba96 100644 --- a/cli/api.js +++ b/cli/api.js @@ -6,13 +6,19 @@ const pify = require('pify'); const recast = require('recast'); const path = require('path'); +// If the user defines XDG_CONFIG_HOME they definitely want their config there, +// otherwise use the home directory in linux/mac and userdata in windows +const applicationDirectory = + process.env.XDG_CONFIG_HOME !== undefined + ? path.join(process.env.XDG_CONFIG_HOME, 'hyper') + : process.platform == 'win32' ? path.join(process.env.APPDATA, 'Hyper') : os.homedir(); + const devConfigFileName = path.join(__dirname, `../.hyper.js`); let fileName = process.env.NODE_ENV !== 'production' && fs.existsSync(devConfigFileName) ? devConfigFileName - : `${os.homedir()}/.hyper.js`; - + : path.join(applicationDirectory, '.hyper.js'); /** * We need to make sure the file reading and parsing is lazy so that failure to * statically analyze the hyper configuration isn't fatal for all kinds of