Skip to content

Commit

Permalink
feat(xdg-compliance): rc file location hierarchy (#1326)
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
tristan957 authored and yyx990803 committed Jun 5, 2018
1 parent 89a0e65 commit ec87266
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/@vue/cli/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@ const { error } = require('@vue/cli-shared-utils/lib/logger')
const { createSchema, validate } = require('@vue/cli-shared-utils/lib/validate')
const { exit } = require('@vue/cli-shared-utils/lib/exit')

const xdgConfigPath = () => {
const xdgConfigHome = process.env.XDG_CONFIG_HOME
if (xdgConfigHome) {
const rcDir = path.join(xdgConfigHome, 'vue')
if (!fs.existsSync(rcDir)) {
fs.mkdirSync(rcDir, 0o700)
}
return path.join(rcDir, '.vuerc')
}

return undefined
}

const rcPath = exports.rcPath = (
process.env.VUE_CLI_CONFIG_PATH ||
xdgConfigPath() ||
path.join(os.homedir(), '.vuerc')
)

Expand Down

0 comments on commit ec87266

Please sign in to comment.