]> Cypherpunks repositories - gostls13.git/commitdiff
misc/wasm: use temporary directory provided by Node.js
authorRichard Musiol <mail@richard-musiol.de>
Tue, 20 Nov 2018 13:47:58 +0000 (14:47 +0100)
committerRichard Musiol <neelance@gmail.com>
Tue, 20 Nov 2018 15:29:09 +0000 (15:29 +0000)
os.TempDir() did not return a proper directory on Windows with js/wasm,
because js/wasm only uses the Unix variant of TempDir.

This commit passes the temporary directory provided by Node.js to the
Go runtime by adding it as a default value for the TMPDIR environment
variable. It makes TempDir compatible with all platforms.

Fixes #27306.

Change-Id: I8b17e44cfb2ca41939ab2a4f918698fe330cb8bc
Reviewed-on: https://go-review.googlesource.com/c/150437
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
misc/wasm/wasm_exec.js

index 440bba104c01df4ac29b84a869c044a0eaee1d68..83704a054f012ae5b711b38d8cc1d237c905c8f9 100644 (file)
 
                const go = new Go();
                go.argv = process.argv.slice(2);
-               go.env = process.env;
+               go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
                go.exit = process.exit;
                WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
                        process.on("exit", (code) => { // Node.js exits if no callback is pending