Atom runs on a number of platforms and while Electron and Node take care of many of the details there are still some considerations to ensure your package works on other operating systems.
File symlinks can be used on Windows by non-Administrators by specifying 'junction' as the type (this argument is ignored on macOS & Linux).
Also consider:
fs.symlink
instead
com1
-com9
, lpt1
-lpt9
, con
, nul
, aux
and prn
(regardless of extension, e.g. prn.txt
is disallowed)"c:\my test"
/my\ test
\
although some tools and PowerShell allow /
too/
You can dynamically find out what your platform uses with path.sep
or better yet use the node path library functions such as join
and normalize
which automatically take care of this.
Windows supports up to 250 characters for a path - avoid deeply nested directory structures
URL parsing routines should not be used on file paths. While they initially look like a relative path it will fail in a number of scenarios on all platforms.
?
as query string, #
as a fragment identifierIf you need to use a path for a URL use the file: protocol with an absolute path instead to ensure drive letters and slashes are appropriately addressed, e.g. file:///c|/test/pic.png
fs.stat
on directoriesThe fs.stat
function does not return the size of the contents of a directory but rather the allocation size of the directory itself. This returns 0 on Windows and 1024 on macOS and so should not be relied upon.
path.relative
can't traverse drivespath.relative
can be used to calculate a relative path to traverse between any two given paths.c:\
and d:\
Creation and deletion operations may take a few milliseconds to complete. If you need to remove many files and folders consider RimRAF which has built-in retry logic for this.
CRLF
LF
autocrlf
set which automatically converts between the twoIf you are writing specs that use text file fixtures consider that this will interfere with file lengths, hash codes and direct text comparisons. It will also change the Atom selection length by 1 character per line.
If you have spec fixtures that are text files you may want to tell Git to force LF, CRLF or not convert them by specifying the paths in .gitattributes
e.g.
spec/fixtures/always-crlf.txt eol=crlf
spec/fixtures/always-lf.txt eol=lf
spec/fixtures/leave-as-is.txt -text