So the reason I was getting so confused in #18 when talking to @jjeising is the same reason why my original commit's message is wrong and the same reason why the current code doesn't work. The reason is that readlink will say a path is not a symbolic link if only part of it is - e.g. /a/b -> /d/e and readlink /a/b/c. Which makes sense when you think about it
The solution I came up with is to use realpath to resolve every path and then see if that's different than the path passed in. I think it beats checking each part manually which is the only other way I can think of, and it also removes one command
Before (done on node-canvas, and /usr/local/opt/* are the symbolic links)
* libpixman-1.0.dylib from /usr/local/opt/pixman/lib/
* libcairo.2.dylib from /usr/local/opt/cairo/lib/
* libpng16.16.dylib from /usr/local/opt/libpng/lib/
* libpangocairo-1.0.0.dylib from /usr/local/opt/pango/lib/
* libpango-1.0.0.dylib from /usr/local/opt/pango/lib/
* libgobject-2.0.0.dylib from /usr/local/opt/glib/lib/
* libglib-2.0.0.dylib from /usr/local/opt/glib/lib/
* libintl.8.dylib from /usr/local/opt/gettext/lib/
* libfreetype.6.dylib from /usr/local/opt/freetype/lib/
* libjpeg.8.dylib from /usr/local/opt/jpeg/lib/
* libgif.4.dylib from /usr/local/opt/giflib/lib/
* libfontconfig.1.dylib from /usr/local/opt/fontconfig/lib/
* libpangoft2-1.0.0.dylib from /usr/local/Cellar/pango/1.38.1/lib/
* libgthread-2.0.0.dylib from /usr/local/opt/glib/lib/
* libharfbuzz.0.dylib from /usr/local/opt/harfbuzz/lib/
* libpcre.1.dylib from /usr/local/opt/pcre/lib/
* libffi.6.dylib from /usr/local/opt/libffi/lib/
After:
* libpixman-1.0.dylib from /usr/local/Cellar/pixman/0.34.0/lib/
symlink --> /usr/local/opt/pixman/lib/libpixman-1.0.dylib
* libcairo.2.dylib from /usr/local/Cellar/cairo/1.14.6_1/lib/
symlink --> /usr/local/opt/cairo/lib/libcairo.2.dylib
* libpng16.16.dylib from /usr/local/Cellar/libpng/1.6.25/lib/
symlink --> /usr/local/opt/libpng/lib/libpng16.16.dylib
* libpangocairo-1.0.0.dylib from /usr/local/Cellar/pango/1.38.1/lib/
symlink --> /usr/local/opt/pango/lib/libpangocairo-1.0.0.dylib
* libpango-1.0.0.dylib from /usr/local/Cellar/pango/1.38.1/lib/
symlink --> /usr/local/opt/pango/lib/libpango-1.0.0.dylib
* libgobject-2.0.0.dylib from /usr/local/Cellar/glib/2.50.1/lib/
symlink --> /usr/local/opt/glib/lib/libgobject-2.0.0.dylib
* libglib-2.0.0.dylib from /usr/local/Cellar/glib/2.50.1/lib/
symlink --> /usr/local/opt/glib/lib/libglib-2.0.0.dylib
* libintl.8.dylib from /usr/local/Cellar/gettext/0.19.8.1/lib/
symlink --> /usr/local/opt/gettext/lib/libintl.8.dylib
* libfreetype.6.dylib from /usr/local/Cellar/freetype/2.7/lib/
symlink --> /usr/local/opt/freetype/lib/libfreetype.6.dylib
* libjpeg.8.dylib from /usr/local/Cellar/jpeg/8d/lib/
symlink --> /usr/local/opt/jpeg/lib/libjpeg.8.dylib
* libgif.4.dylib from /usr/local/Cellar/giflib/4.2.3/lib/
symlink --> /usr/local/opt/giflib/lib/libgif.4.dylib
* libfontconfig.1.dylib from /usr/local/Cellar/fontconfig/2.12.1_2/lib/
symlink --> /usr/local/opt/fontconfig/lib/libfontconfig.1.dylib
* libpangoft2-1.0.0.dylib from /usr/local/Cellar/pango/1.38.1/lib/
* libgthread-2.0.0.dylib from /usr/local/Cellar/glib/2.50.1/lib/
symlink --> /usr/local/opt/glib/lib/libgthread-2.0.0.dylib
* libharfbuzz.0.dylib from /usr/local/Cellar/harfbuzz/1.2.6/lib/
symlink --> /usr/local/opt/harfbuzz/lib/libharfbuzz.0.dylib
* libpcre.1.dylib from /usr/local/Cellar/pcre/8.39/lib/
symlink --> /usr/local/opt/pcre/lib/libpcre.1.dylib
* libffi.6.dylib from /usr/local/Cellar/libffi/3.0.13/lib/
symlink --> /usr/local/opt/libffi/lib/libffi.6.dylib
So the reason I was getting so confused in #18 when talking to @jjeising is the same reason why my original commit's message is wrong and the same reason why the current code doesn't work. The reason is that
readlink
will say a path is not a symbolic link if only part of it is - e.g./a/b -> /d/e
andreadlink /a/b/c
. Which makes sense when you think about itThe solution I came up with is to use
realpath
to resolve every path and then see if that's different than the path passed in. I think it beats checking each part manually which is the only other way I can think of, and it also removes one commandBefore (done on node-canvas, and
/usr/local/opt/*
are the symbolic links)After: