UNPKG

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

Version:

Cordova plugin exposing Sumsub SDK

63 lines (49 loc) 2.28 kB
'use strict'; var fs = require('fs'); module.exports = function (context) { var withFisherman = process.argv.includes('--with-Fisherman') 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 (!withFisherman && !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 = '13.0' if (withFisherman) { replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/Fisherman')) } 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" : ""))) } 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') }) }