UNPKG

@sumsub/cordova-idensic-mobile-sdk-plugin

Version:

Cordova plugin exposing Sumsub SDK

62 lines (48 loc) 2.15 kB
'use strict'; var fs = require('fs'); module.exports = function (context) { var withEID = process.argv.includes('--with-EID') var withMRTDReader = process.argv.includes('--with-MRTDReader') var withMRTDReaderCompat = process.argv.includes('--with-MRTDReader-compat') var withVideoIdent = process.argv.includes('--with-VideoIdent') var withVideoIdentCompat = process.argv.includes('--with-VideoIdent-compat') withMRTDReader = withMRTDReader || withMRTDReaderCompat withVideoIdent = withVideoIdent || withVideoIdentCompat if (!withEID && !withMRTDReader && !withVideoIdent) { return } var podfilePath = './platforms/ios/Podfile' fs.stat(podfilePath, function (error, stat) { if (error) { return } var podfileContent = fs.readFileSync(podfilePath, 'utf8') var platformLineRe = /^\s*platform :ios, ['"](.*?)['"]\s*$/m var podLineRe = /^.*IdensicMobileSDK.*$/m var matches = podfileContent.match(podLineRe) if (!matches) { return } var podLine = matches[0] var replaces = [podLine] var minTarget = '12.0' if (withEID) { replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/EID')) } if (withMRTDReader) { replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/MRTDReader' + (withMRTDReaderCompat ? "-compat" : ""))) } if (withVideoIdent) { replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/VideoIdent' + (withVideoIdentCompat ? "-compat" : ""))) if (!withVideoIdentCompat) { minTarget = '12.2' } } var platformMatches = podfileContent.match(platformLineRe) if (platformMatches && platformMatches[1] < minTarget) { podfileContent = podfileContent.replace(platformMatches[0], "platform :ios, '" + minTarget + "'\n" ) } podfileContent = podfileContent.replace(podLineRe, replaces.join("\n")) fs.writeFileSync(podfilePath, podfileContent, 'utf8') }) }