NickHeiner / jscodemod

Codemod runner
MIT License
41 stars 4 forks source link

Do atomic writes #35

Closed NickHeiner closed 2 years ago

NickHeiner commented 2 years ago

Previously, the workflow was for each worker to write its own changed files. This meant we could have a race condition if a one thread modified a file and another thread read that file. (For instance, a codemod that converts CJS to ESM and needs to read other files to see if they use default or named exports.)

By centralizing writes in the parent thread, we avoid this issue. And we make it easier later to do things like "only write a certain count of files".