File tree Expand file tree Collapse file tree 3 files changed +40
-17
lines changed Expand file tree Collapse file tree 3 files changed +40
-17
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,12 @@ const cloneDeep = require('lodash.clonedeep')
55const { error } = require ( '@vue/cli-shared-utils/lib/logger' )
66const { createSchema, validate } = require ( '@vue/cli-shared-utils/lib/validate' )
77const { exit } = require ( '@vue/cli-shared-utils/lib/exit' )
8- const { xdgConfigPath } = require ( './util/xdgConfig ' )
8+ const { xdgConfigPath, windowsConfigPath } = require ( './util/rcPath ' )
99
1010const rcPath = exports . rcPath = (
1111 process . env . VUE_CLI_CONFIG_PATH ||
12- xdgConfigPath ( '.vuerc' ) ||
12+ xdgConfigPath ( ) ||
13+ windowsConfigPath ( ) ||
1314 path . join ( os . homedir ( ) , '.vuerc' )
1415)
1516
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
2+ const os = require ( 'os' )
3+ const path = require ( 'path' )
4+
5+ exports . xdgConfigPath = ( ) => {
6+ const xdgConfigHome = process . env . XDG_CONFIG_HOME
7+ if ( xdgConfigHome ) {
8+ const rcDir = path . join ( xdgConfigHome , 'vue' )
9+ if ( ! fs . existsSync ( rcDir ) ) {
10+ fs . mkdirSync ( rcDir , 0o700 )
11+ }
12+ return path . join ( rcDir , '.vuerc' )
13+ }
14+ }
15+
16+ exports . windowsConfigPath = file => {
17+ if ( process . platform !== 'win32' ) {
18+ return
19+ }
20+ const appData = process . env . APPDATA
21+ if ( appData ) {
22+ const rcDir = path . join ( appData , 'vue' )
23+ if ( ! fs . existsSync ( rcDir ) ) {
24+ fs . mkdirSync ( rcDir )
25+ }
26+ const rcPath = path . join ( rcDir , '.vuerc' )
27+ // migration for < 3.0.0-rc.7
28+ const oldRcFile = path . join ( os . homedir ( ) , '.vuerc' )
29+ if ( fs . existsSync ( oldRcFile ) ) {
30+ fs . writeFileSync ( rcPath , fs . readFileSync ( oldRcFile ) )
31+ const chalk = require ( 'chalk' )
32+ console . log ( `Detected ${ chalk . cyan ( `.vuerc` ) } in ${ chalk . cyan ( path . dirname ( oldRcFile ) ) } ...` )
33+ console . log ( `Migrated to ${ chalk . cyan ( rcPath ) } .` )
34+ }
35+ return rcPath
36+ }
37+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments