(baseFilename)
| 99 | * @returns |
| 100 | */ |
| 101 | const getRcLocalConfig = async (baseFilename) => { |
| 102 | const localConfigPath = getRcLocalPath(baseFilename) |
| 103 | try { |
| 104 | const localConfig = await readFile(localConfigPath) |
| 105 | if (!localConfig) return null |
| 106 | return JSON.parse(localConfig) |
| 107 | } catch (error) { |
| 108 | if (error.code === 'ENOENT') return {} |
| 109 | try { |
| 110 | // try/catch to account for very unlikely race condition where file existed |
| 111 | // during readFileSync but no longer exists during rename |
| 112 | const backupRcPath = `${localConfigPath}.bak` |
| 113 | await fsp.rename(localConfigPath, backupRcPath) |
| 114 | } catch { |
| 115 | // Ignore |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | return {} |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Gets the .{baseFilename}rc configuration file in the user's home directory, if it exists. |
no test coverage detected