Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
destination = filePath
} else {
destination = file.createWriteStream()
}
await this.emitter.emitAsync('will-save', {path: filePath})
try {
await this.buffer.save(destination, this.getEncoding())
} catch (error) {
const canEscalate = process.platform === 'darwin' || process.platform === 'linux'
if (error.code === 'EACCES' && destination === filePath && canEscalate) {
const fsAdmin = require('fs-admin')
try {
await this.buffer.save(fsAdmin.createWriteStream(filePath), this.getEncoding())
} catch (_) {
throw error
}
} else {
throw error
}
}
} finally {
this.outstandingSaveCount--
}
this.setFile(file)
this.fileHasChangedSinceLastLoad = false
this.digestWhenLastPersisted = this.buffer.baseTextDigest()
this.loaded = true
this.emitModifiedStatusChanged(false)