UNPKG

nativescript

Version:

Command-line interface for building NativeScript projects

67 lines 2.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.XcconfigService = void 0; const path = require("path"); const constants_1 = require("../common/constants"); const yok_1 = require("../common/yok"); class XcconfigService { constructor($childProcess, $fs) { this.$childProcess = $childProcess; this.$fs = $fs; } getPluginsXcconfigFilePaths(projectRoot) { return { [constants_1.Configurations.Debug.toLowerCase()]: this.getPluginsDebugXcconfigFilePath(projectRoot), [constants_1.Configurations.Release.toLowerCase()]: this.getPluginsReleaseXcconfigFilePath(projectRoot), }; } getPluginsDebugXcconfigFilePath(projectRoot) { return path.join(projectRoot, "plugins-debug.xcconfig"); } getPluginsReleaseXcconfigFilePath(projectRoot) { return path.join(projectRoot, "plugins-release.xcconfig"); } async mergeFiles(sourceFile, destinationFile) { if (!this.$fs.exists(destinationFile)) { this.$fs.writeFile(destinationFile, ""); } const escapedDestinationFile = destinationFile.replace(/'/g, "\\'"); const escapedSourceFile = sourceFile.replace(/'/g, "\\'"); const mergeScript = `require 'xcodeproj'; userConfig = Xcodeproj::Config.new('${escapedDestinationFile}') existingConfig = Xcodeproj::Config.new('${escapedSourceFile}') userConfig.attributes.each do |key,| existingConfig.attributes.delete(key) if (userConfig.attributes.key?(key) && existingConfig.attributes.key?(key)) end userConfig.merge(existingConfig).save_as(Pathname.new('${escapedDestinationFile}'))`; await this.$childProcess.exec(`ruby -e "${mergeScript}"`); } readPropertyValue(xcconfigFilePath, propertyName) { if (this.$fs.exists(xcconfigFilePath)) { const text = this.$fs.readText(xcconfigFilePath); let property; let isPropertyParsed = false; text.split(/\r?\n/).forEach((line) => { line = line.replace(/\/(\/)[^\n]*$/, ""); if (line.indexOf(propertyName) >= 0) { const parts = line.split("="); if (parts.length > 1 && parts[1]) { property = parts[1].trim(); isPropertyParsed = true; if (property[property.length - 1] === ";") { property = property.slice(0, -1); } } } }); if (isPropertyParsed) { // property can be an empty string, so we don't check for that. return property; } } return null; } } exports.XcconfigService = XcconfigService; yok_1.injector.register("xcconfigService", XcconfigService); //# sourceMappingURL=xcconfig-service.js.map