From c6d125080d233b07d434673076ebd62d8943b3f8 Mon Sep 17 00:00:00 2001 From: Zhuo Lu Date: Tue, 20 Jun 2017 01:03:59 +0800 Subject: [PATCH] Allow array of ignore options Doc updated for opts.ignore --- README.md | 5 +++-- bin/electron-osx-sign-usage.txt | 4 ++-- sign.js | 15 ++++++++------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6062517..bd06975 100644 --- a/README.md +++ b/README.md @@ -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* diff --git a/bin/electron-osx-sign-usage.txt b/bin/electron-osx-sign-usage.txt index dae0bdd..0b587c1 100644 --- a/bin/electron-osx-sign-usage.txt +++ b/bin/electron-osx-sign-usage.txt @@ -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. diff --git a/sign.js b/sign.js index baaa1f4..af41f04 100644 --- a/sign.js +++ b/sign.js @@ -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']) { @@ -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 }