jscodeshift icon indicating copy to clipboard operation
jscodeshift copied to clipboard

Potential minor bug: temp's tracking feature is not used

Open nickmccurdy opened this issue 7 years ago • 1 comments

Without using temp.track(), it no longer automatically tracks the files to clean up. Because jscodeshift uses temp.cleanupSync() (instead of temp.cleanup(), which passes errors when temp.track() is not used), errors may be silenced and temporary files may remain after jscodeshift's processes close.

From temp's readme:

Want Cleanup? Make sure you ask for it.

As noted in the example above, if you want temp to track the files and directories it creates and handle removing those files and directories on exit, you must call track(). The track() function is chainable, and it's recommended that you call it when requiring the module.

var temp = require("temp").track();

Why is this necessary? In pre-0.6 versions of temp, tracking was automatic. While this works great for scripts and Grunt tasks, it's not so great for long-running server processes. Since that's arguably what Node.js is for, you have to opt-in to tracking.

But it's easy.

nickmccurdy avatar Dec 10 '16 10:12 nickmccurdy

Hm, I started a fix but I realized that tempUtils.renameFileTo() will need to be changed to inform temp of the file renaming. I might have a PR soon.

nickmccurdy avatar Dec 26 '16 19:12 nickmccurdy