Path to file incorrect on Windows


Hello everyone,

I have a problem with different paths to files on Mac and Windows. The file path is correct on Mac, wrong on windows.

My package is called emoji-syntax. What I do is, dynamically creating a stylesheet and adding this to atom.stylesElement to display emoji next to language selectors like .source.js .meta.import .keyword:first-child:before. It feels a bit wrong though, but it works for me.

Now what I am doing is, I want to have custom emoji sets and replace the unicode with an SVG. This works all fine on Mac, but not on Windows where the path to the file is wrong.

To get the path I use atom.packages.resolvePackagePath('emoji-syntax') and then reference to the file in my CSS. I get the correct link on Windows too, but somehow it’s doubled.

The two paths look like this:

  • Mac (correct): file:///Users/morkro/.atom/packages/emoji-syntax/styles/twemoji/1f4e5.svg
  • Windows (incorrect): file:///C:/Users/morkro/AppData/Local/atom/app-1.7.3/resources/app.asar/static/C:/Users/morkro/.atom/packages/emoji-syntax/styles/twemoji/1f4e5.svg

This is a little bit confusing to me and I hope I could explain my problem exactly. Basically, what I want to know: How do I get the correct path to a file in my package on Windows and Mac?



As I mentioned in Slack, you can use the technique I employed in my red-wavy-underline package as seen here: