append file flag fix

This commit is contained in:
dmc
2024-01-15 19:58:04 +01:00
parent d28d55fab8
commit 7d8edc64f0

View File

@@ -105,7 +105,6 @@ customElements.define('system-status', class extends HTMLElement {
this.shellProfiles[file] = { filepath, hasPear: this.stmtrx.test(contents) } this.shellProfiles[file] = { filepath, hasPear: this.stmtrx.test(contents) }
hasPear = hasPear || this.shellProfiles[file].hasPear hasPear = hasPear || this.shellProfiles[file].hasPear
} }
console.log('hi', contents, hasPear, this.stmtrx, this.shellProfiles[file])
} }
if (hasPear) process.env.PATH = `${BIN}:${process.env.PATH}` if (hasPear) process.env.PATH = `${BIN}:${process.env.PATH}`
} }
@@ -151,13 +150,13 @@ customElements.define('system-status', class extends HTMLElement {
const profiles = Object.values(this.shellProfiles) const profiles = Object.values(this.shellProfiles)
if (profiles.length > 0) { if (profiles.length > 0) {
for (const { filepath, hasPear } of profiles) { for (const { filepath, hasPear } of profiles) {
if (hasPear === false) fs.writeFileSync(filepath, this.statement, { flags: 'a' }) if (hasPear === false) fs.writeFileSync(filepath, this.statement, { flag: 'a' })
} }
} else { } else {
const bash = this.paths.some((bin) => fs.existsSync(path.join(bin, 'bash'))) const bash = this.paths.some((bin) => fs.existsSync(path.join(bin, 'bash')))
const zsh = this.paths.some((bin) => fs.existsSync(path.join(bin, 'zsh'))) const zsh = this.paths.some((bin) => fs.existsSync(path.join(bin, 'zsh')))
fs.writeFileSync(path.join(os.homedir(), bash ? '.bashrc' : '.profile'), this.statement + '\n', { flags: 'a' }) fs.writeFileSync(path.join(os.homedir(), bash ? '.bashrc' : '.profile'), this.statement + '\n', { flag: 'a' })
if (zsh) fs.writeFileSync(path.join(os.homedir(), '.zshrc'), this.statement + '\n', { flags: 'a' }) if (zsh) fs.writeFileSync(path.join(os.homedir(), '.zshrc'), this.statement + '\n', { flag: 'a' })
} }
const pear = path.join(BIN, 'pear') const pear = path.join(BIN, 'pear')