Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
clean-write
Advanced tools
Cleanup corrupted files on write errors.
When an exception is thrown while a file is being written, that file will be
corrupted. The same problem occurs when the process exits unexpectedly (for
example with CTRL-C
).
This library removes corrupted files in such cases.
const cleanWrite = require('clean-write')
const { writeFile } = require('fs')
const { promisify } = require('util')
const writeFileAsync = promisify(writeFile)
const filePath = './path/to/file.js'
const writeFunction = async function() {
await writeFileAsync(filePath, 'example')
}
// If an exception happens or if the program exits, the file will be removed
await cleanWrite(writeFunction, filePath)
npm install clean-write
writeFunction
: () => Promise<void>
filePath
: string
Returns:
Promise<void>
The file is removed if either:
writeFunction()
throws an exception or returns a rejected Promise
writeFunction()
completesIf you found a bug or would like a new feature, don't hesitate to submit an issue on GitHub.
For other questions, feel free to chat with us on Gitter.
Everyone is welcome regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.
This project was made with ❤️. The simplest way to give back is by starring and sharing it online.
If the documentation is unclear or has a typo, please click on the page's Edit
button (pencil icon) and suggest a correction.
If you would like to help us fix a bug or add a new feature, please check our guidelines. Pull requests are welcome!
ehmicky 💻 🎨 🤔 📖 |
FAQs
Cleanup corrupted files on write errors
We found that clean-write demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.