Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, readFileSync } from 'node:fs'
import { existsSync, readFileSync, mkdirSync } from 'node:fs'
import { homedir } from 'node:os'
import { resolve } from 'node:path'

Expand Down Expand Up @@ -154,9 +154,16 @@ async function _checkDisabled(dir: string): Promise<string | false | undefined>
return 'by ' + resolve(dir, RC_FILENAME)
}

// This is maintained for backward compatibility
if (disabledByConf(rc.readUser({ name: RC_FILENAME }))) {
return 'by ' + resolve(homedir(), RC_FILENAME)
}

if (disabledByConf(rc.readUserConfig({ name: RC_FILENAME }))) {
// Uses the same resolving logic as rc9
const rc9Base = process.env.XDG_CONFIG_HOME || resolve(homedir(), '.config')
return 'by ' + resolve(rc9Base, RC_FILENAME)
}
}

async function showStatus(dir: string, global: boolean) {
Expand All @@ -172,7 +179,11 @@ async function showStatus(dir: string, global: boolean) {
function setRC(dir: string, key: any, val: any, global: boolean) {
const update = { [key]: val }
if (global) {
rc.updateUser(update, RC_FILENAME)
// Uses the same resolving logic as rc9
const rc9Base = process.env.XDG_CONFIG_HOME || resolve(homedir(), '.config')
// Make sure the directory exists before rc9 attempt to write there
mkdirSync(rc9Base, { recursive: true })
rc.updateUserConfig(update, RC_FILENAME)
}
else {
rc.update(update, { name: RC_FILENAME, dir })
Expand Down
11 changes: 9 additions & 2 deletions src/utils/nuxtrc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { updateUser } from 'rc9'
import { updateUserConfig } from 'rc9'
import { homedir } from 'node:os'
import { resolve } from 'node:path'
import { mkdirSync } from 'node:fs'

export function updateUserNuxtRc(key: string, val: string | number | boolean) {
updateUser({ [key]: val }, '.nuxtrc')
// Uses the same resolving logic as rc9
const rc9Base = process.env.XDG_CONFIG_HOME || resolve(homedir(), '.config')
// Make sure the directory exists before rc9 attempt to write there
mkdirSync(rc9Base, { recursive: true })
updateUserConfig({ [key]: val }, '.nuxtrc')
}