.DS_Store file is "required" by node if found in the images directory

If a .DS_Store file is created by OS X in the images directory then natal will attempt to
require it like any other image file. This causes an error in the simulator as javascript cannot load
the file. As there isnt any reason why a .DS_Store file should be loaded I've added an automatic exclusion for this file
name in any part of the image path.

Additions that could be made:

We could expose the exclude list as a configuration in the .re-natal file so that people could see what is being excluded and add to it if needed.
This commit is contained in:
Mark Lakewood 2016-05-11 12:00:02 -07:00
parent 9e610170cd
commit 180427e6b6
1 changed files with 6 additions and 1 deletions

View File

@ -216,15 +216,20 @@ scanImageDir = (dir) ->
fnames = fs.readdirSync(dir)
.map (fname) -> "#{dir}/#{fname}"
.filter (path) -> fs.statSync(path).isFile()
.filter (path) -> removeExcludeFiles(path)
.map (path) -> path.replace /@2x|@3x/i, ''
.filter (v, idx, slf) -> slf.indexOf(v) == idx
dirs = fs.readdirSync(dir)
.map (fname) -> "#{dir}/#{fname}"
.filter (path) -> fs.statSync(path).isDirectory()
fnames.concat scanImages(dirs)
removeExcludeFiles = (file) ->
excludedFileNames = [".DS_Store"]
res = excludedFileNames.map (ex) -> (file.indexOf ex) == -1
true in res
scanImages = (dirs) ->
imgs = []
for dir in dirs