File tree Expand file tree Collapse file tree
cli-ui/src/graphql-api/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const Lowdb = require ( 'lowdb' )
22const FileSync = require ( 'lowdb/adapters/FileSync' )
33const fs = require ( 'fs-extra' )
4- const { resolve } = require ( 'path' )
4+ const path = require ( 'path' )
5+ const os = require ( 'os' )
6+ const { xdgConfigPath } = require ( '@vue/cli/lib/util/xdgConfig' )
57
6- let folder = '../../../live'
8+ let folder
79
810if ( process . env . VUE_CLI_UI_TEST ) {
911 folder = '../../../live-test'
1012 // Clean DB
11- fs . removeSync ( resolve ( __dirname , folder ) )
13+ fs . removeSync ( path . resolve ( __dirname , folder ) )
14+ } else {
15+ folder = process . env . VUE_CLI_UI_DB_PATH ||
16+ xdgConfigPath ( '.vue-cli-ui' ) ||
17+ path . join ( os . homedir ( ) , '.vue-cli-ui' )
1218}
1319
14- fs . ensureDirSync ( resolve ( __dirname , folder ) )
20+ fs . ensureDirSync ( path . resolve ( __dirname , folder ) )
1521
16- const db = new Lowdb ( new FileSync ( resolve ( __dirname , folder , 'db.json' ) ) )
22+ const db = new Lowdb ( new FileSync ( path . resolve ( __dirname , folder , 'db.json' ) ) )
1723
1824// Seed an empty DB
1925db . defaults ( {
Original file line number Diff line number Diff line change @@ -5,23 +5,11 @@ 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-
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- }
8+ const { xdgConfigPath } = require ( './util/xdgConfig' )
219
2210const rcPath = exports . rcPath = (
2311 process . env . VUE_CLI_CONFIG_PATH ||
24- xdgConfigPath ( ) ||
12+ xdgConfigPath ( '.vuerc' ) ||
2513 path . join ( os . homedir ( ) , '.vuerc' )
2614)
2715
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
2+ const path = require ( 'path' )
3+
4+ exports . xdgConfigPath = ( file ) => {
5+ const xdgConfigHome = process . env . XDG_CONFIG_HOME
6+ if ( xdgConfigHome ) {
7+ const rcDir = path . join ( xdgConfigHome , 'vue' )
8+ if ( ! fs . existsSync ( rcDir ) ) {
9+ fs . mkdirSync ( rcDir , 0o700 )
10+ }
11+ return path . join ( rcDir , file )
12+ }
13+
14+ return undefined
15+ }
You can’t perform that action at this time.
0 commit comments