Skip to content

Commit

Permalink
work around unfortunate windows ci limiations
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Feb 5, 2021
1 parent 6a995fb commit 82f7a0a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,14 @@ module.exports = ${JSON.stringify(exit0Map, null, 2)};
// want to read the file after it has been truncated but before the new contents
// have been written.
exports.writeFileAtomic = (where, contents) => {
const file = path.join(os.tmpdir(), 'esbuild-atomic-file-' + Math.random().toString(36).slice(2))
// Note: Can't use "os.tmpdir()" because that doesn't work on Windows. CI runs
// tests on D:\ and the temporary directory is on C:\ or the other way around.
// And apparently it's impossible to move files between C:\ and D:\ or something.
// So we have to write the file in the same directory as the destination. This is
// unfortunate because it will unnecessarily trigger extra watch mode rebuilds.
// So we have to make our tests extra robust so they can still work with random
// extra rebuilds thrown in.
const file = path.join(path.dirname(where), '.esbuild-atomic-file-' + Math.random().toString(36).slice(2))
fs.writeFileSync(file, contents)
fs.renameSync(file, where)
}
Expand Down

0 comments on commit 82f7a0a

Please sign in to comment.