From b5c221fe68aaa688dd0e337c70dad9c0c879423d Mon Sep 17 00:00:00 2001 From: Tal Hayut Date: Fri, 20 Apr 2018 18:02:30 +0300 Subject: [PATCH] CLI: use .hyper.js from repo root dir when running in dev mode (#2792) --- .vscode/launch.json | 9 +++++++++ cli/api.js | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 4981a61b..9f50ef8f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,6 +8,15 @@ "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", "program": "${workspaceRoot}/app/index.js", "protocol": "inspector" + }, + { + "type": "node", + "request": "launch", + "name": "cli", + "runtimeExecutable": "node", + "program": "${workspaceRoot}/bin/cli.js", + "args": ["--help"], + "protocol": "inspector" } ] } diff --git a/cli/api.js b/cli/api.js index 035923f6..a3e924ab 100644 --- a/cli/api.js +++ b/cli/api.js @@ -4,8 +4,14 @@ const got = require('got'); const registryUrl = require('registry-url')(); const pify = require('pify'); const recast = require('recast'); +const path = require('path'); -const fileName = `${os.homedir()}/.hyper.js`; +const devConfigFileName = path.join(__dirname, `../.hyper.js`); + +let fileName = + process.env.NODE_ENV !== 'production' && fs.existsSync(devConfigFileName) + ? devConfigFileName + : `${os.homedir()}/.hyper.js`; /** * We need to make sure the file reading and parsing is lazy so that failure to