Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow array of ignore options #142

Merged
merged 1 commit into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ Default to `true`.
The keychain name.
Default to system default keychain.

`ignore` - *String*
`ignore` - *RegExp|Function|Array.<(RegExp|Function)>*

Regex or function that signals ignoring a file before signing.
Regex, function or an array of regex's and functions that signal to skip signing a file.
Elements of other types are converted to `RegExp` automatically.
Default to `undefined`.

`platform` - *String*
Expand Down
4 changes: 2 additions & 2 deletions bin/electron-osx-sign-usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ DESCRIPTION
--identity-validation, --no-identity-validation
Flag to enable/disable validation for the signing identity.

--ignore=regex
Regex that signals ignoring a file before signing.
--ignore=path
Path to skip signing.

--keychain=keychain
The keychain name.
Expand Down
15 changes: 8 additions & 7 deletions sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function validateOptsBinariesAsync (opts) {
* @returns {Promise} Promise.
*/
function validateSignOptsAsync (opts) {
if (opts.ignore) {
if (typeof opts.ignore !== 'function' && typeof opts.ignore !== 'string') return Promise.reject(new Error('Ignore filter should be either a function or a string.'))
if (opts.ignore && !(opts.ignore instanceof Array)) {
opts.ignore = [opts.ignore]
}

if (opts['provisioning-profile']) {
Expand Down Expand Up @@ -122,11 +122,12 @@ function signApplicationAsync (opts) {
.then(function (childPaths) {
function ignoreFilePath (opts, filePath) {
if (opts.ignore) {
if (typeof opts.ignore === 'function') {
return opts.ignore(filePath)
} else if (typeof opts.ignore === 'string') {
return filePath.match(opts.ignore)
}
return opts.ignore.some(function (ignore) {
if (typeof ignore === 'function') {
return ignore(filePath)
}
return filePath.match(ignore)
})
}
return false
}
Expand Down