From b3166ef9d482bb8859e7fdea2ad9bf6240601b54 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Mon, 20 Mar 2017 09:35:51 -0700 Subject: [PATCH] yarnrc: respect XDG_CONFIG_HOME setting If a user has a XDG_CONFIG_HOME environment variable, read and write the yarnrc file from XDG_CONFIG_HOME/.yarnrc, not from $HOME/.yarnrc. The specification can be found here: https://wiki.archlinux.org/index.php/XDG_Base_Directory_support Fixes #2334. --- src/registries/yarn-registry.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/registries/yarn-registry.js b/src/registries/yarn-registry.js index d000c0ead6..d31194ae53 100644 --- a/src/registries/yarn-registry.js +++ b/src/registries/yarn-registry.js @@ -46,7 +46,11 @@ export default class YarnRegistry extends NpmRegistry { constructor(cwd: string, registries: ConfigRegistries, requestManager: RequestManager) { super(cwd, registries, requestManager); - this.homeConfigLoc = path.join(userHome, '.yarnrc'); + if (process.env.XDG_CONFIG_HOME) { + this.homeConfigLoc = path.join(process.env.XDG_CONFIG_HOME, '.yarnrc'); + } else { + this.homeConfigLoc = path.join(userHome, '.yarnrc'); + } this.homeConfig = {}; }