ast-types
ast-types copied to clipboard
fix #266.
Also, the code in run.sh
makes sure the target directories in /tmp/ are cleaned before both repos are cloned in there to ensure nothing untoward gets into /test/data/
Sorry for the delay on these issues/PRs!
Is there always a /tmp/
directory on Windows? Maybe we should use os.tmpdir()
for portability?
There is a kind of /tmp/ on Windows, referenced via the environment variable %TEMP% ($TEMP in bash). There's also %TMPDIR% ($TMPDIR in bash). See also:
- https://superuser.com/questions/709953/temp-vs-tmp-in-environment-variables
- but all those env vars don't need to point to the same temp dir. This can be also gleaned from the Remarks section of this API: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx
However, I don't think we need to go that deep to have something which works for ast-types (and NodeJS/NPM task scripts):
I use git-for-windows, which also delivers bash
onto the system and I expect most people to use that rig or a very similar one (mingw, etc.) where the UNIX environment is mimicked as much as possible, including a /tmp/
directory which is mapped internally to a Windows temp dir that's accessible & usable.
I use /tmp/ in my bash shell scripts on Windows and that's fine; the key thing here is that as soon as you run bash
you've entered UNIX-Emulation-Land and thus can very reasonably expect a working /tmp/
to be available to your script.
When you don't require bash but instead build your tasks in JavaScript, then os.tmpdir() would indeed be needed as you most probably don't live within the bash
shell then but CMD
or PowerShell instead. Which do not have /tmp/
but only %TMP%, %TEMP% and %TMPDIR%.
Anyway, that's the low-down on Windows temp dir(s). When it's up to me, I'd say stick with bash scripts and Windows users can go and install one of the bash/UNIXy build environments. They will have 99.5% of the time as there's a lot of stuff that's easier to do then.
Production environments and such may well have a naked NodeJS install, but then you won't be running NPM there either, so ast-types may be there, but not the npm run xyz
tasks that come with it: they'll have been run on another box.
HTH