Skip to content

Commit

Permalink
Allow array of ignore options
Browse files Browse the repository at this point in the history
Doc updated for opts.ignore
  • Loading branch information
sethlu committed Jun 20, 2017
1 parent 238d12c commit c6d1250
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
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

0 comments on commit c6d1250

Please sign in to comment.