Prevent writing the same file several times (fixes #3753)

Could `jsPath` ever have a value like "toString" or "hasOwnProperty" (e.g. by compiling a file named like that)? If that's the case then this could break.