Search code examples
electronelectron-packager

How to delete all .DS_Store when packaging with electron-packager?


When building packages with electron-packager on Mac OS X, I want to ignore all .DS_store files in my project folder.

.DS_Store should not be included in my packages.

Should I use an option of electron-packager or an other solution?


Solution

  • You can use the ignore option of electron-packager to skip files matching a certain regular expression:

    electron-packager . MyApp \
        --asar \
        --platform=darwin \
        --arch=x64 \
        --prune=true \
        --ignore='\.DS_Store'
    

    The backslashes at the end of each line allow to continue the command on the next line. You escape the newline, so make sure there are no characters (e.g. spaces) after the backslash.

    The backslash in the ignore parameter escapes the ., which otherwise matches any character. Once it's escaped, it matches only the character ..