Skip to content

Commit ec87266

Browse files
tristan957yyx990803
authored andcommittedJun 5, 2018
feat(xdg-compliance): rc file location hierarchy (#1326)
`vue-cli` now uses the following hierarchy for hosting its rc file: * `VUE_CLI_CONFIG_PATH * `XDG_CONFIG_HOME/vue/.vuerc` * `HOME/.config/vue/.vuerc` * `HOME/.vuerc` closes #1325
1 parent 89a0e65 commit ec87266

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎packages/@vue/cli/lib/options.js

+14
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@ const { error } = require('@vue/cli-shared-utils/lib/logger')
66
const { createSchema, validate } = require('@vue/cli-shared-utils/lib/validate')
77
const { exit } = require('@vue/cli-shared-utils/lib/exit')
88

9+
const xdgConfigPath = () => {
10+
const xdgConfigHome = process.env.XDG_CONFIG_HOME
11+
if (xdgConfigHome) {
12+
const rcDir = path.join(xdgConfigHome, 'vue')
13+
if (!fs.existsSync(rcDir)) {
14+
fs.mkdirSync(rcDir, 0o700)
15+
}
16+
return path.join(rcDir, '.vuerc')
17+
}
18+
19+
return undefined
20+
}
21+
922
const rcPath = exports.rcPath = (
1023
process.env.VUE_CLI_CONFIG_PATH ||
24+
xdgConfigPath() ||
1125
path.join(os.homedir(), '.vuerc')
1226
)
1327

0 commit comments

Comments
 (0)
Please sign in to comment.