How to use the parse function from plist
Find comprehensive JavaScript plist.parse code examples handpicked from public code repositorys.
The plist.parse function parses a property list (plist) file format into a JavaScript object.
194 195 196 197 198 199 200 201 202 203
var originalName = path.basename(locations.xcodeCordovaProj); // Update package id (bundle id) var plistFile = path.join(locations.xcodeCordovaProj, originalName + '-Info.plist'); var infoPlist = plist.parse(fs.readFileSync(plistFile, 'utf8')); infoPlist['CFBundleIdentifier'] = pkg; // Update version (bundle version) infoPlist['CFBundleShortVersionString'] = version;
+ 2 other calls in file
GitHub: RubinLab/epadlite
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
fastify.decorate( 'parseOsirix', (docPath) => new Promise((resolve, reject) => { try { const osirixObj = plist.parse(fs.readFileSync(docPath, 'utf8')); resolve(osirixObj); } catch (err) { reject(err); }
How does plist.parse work?
The plist.parse function is a part of the plist library and is used to parse a property list (plist) file format into a JavaScript object. To accomplish this, the parse function first reads the contents of the plist file and converts it into an XML Document Object Model (DOM). Next, the function walks through the DOM tree and creates a JavaScript object that mirrors the structure of the plist file. The function maps each node type in the DOM tree to a corresponding JavaScript data type, such as arrays, objects, numbers, booleans, or strings. If the parse function encounters a dict node in the DOM tree, it creates an object in the resulting JavaScript object with the key elements as the property names and the value elements as the corresponding property values. If the parse function encounters an array node in the DOM tree, it creates an array in the resulting JavaScript object with the child elements as the array elements. If the parse function encounters a string, real, or integer node in the DOM tree, it creates a corresponding JavaScript string, number, or integer in the resulting object. Finally, the parse function returns the resulting JavaScript object representing the parsed plist file. By using the plist.parse function, developers can read and convert plist files to a more accessible and understandable format, like JavaScript objects, which can be further used to perform operations, such as data analysis, transformation, or visualization.
186 187 188 189 190 191 192 193 194 195
const originalName = path.basename(locations.xcodeCordovaProj); // Update package id (bundle id) const plistFile = path.join(locations.xcodeCordovaProj, `${originalName}-Info.plist`); const infoPlist = plist.parse(fs.readFileSync(plistFile, 'utf8')); // Update version (bundle version) infoPlist.CFBundleShortVersionString = version; const CFBundleVersion = platformConfig.getAttribute('ios-CFBundleVersion') || default_CFBundleVersion(version);
GitHub: FRC-6390/frc-prodromoi
117 118 119 120 121 122 123 124 125 126 127
}; Patcher.prototype.fixATS = function() { return this.__forEachFile('**/*Info.plist', CONFIG_LOCATION, function(filename) { try { var data = plist.parse(fs.readFileSync(filename, 'utf-8')); data.NSAppTransportSecurity = { NSAllowsArbitraryLoads: true }; fs.writeFileSync(filename, plist.build(data));
Ai Example
1 2 3 4 5 6 7
const plist = require("plist"); const fs = require("fs"); const contents = fs.readFileSync("example.plist", "utf8"); const result = plist.parse(contents); console.log(result);
In this example, we're using the plist library to parse a plist file named example.plist into a JavaScript object. We use the fs.readFileSync method to read the contents of the example.plist file into a string. We then use the plist.parse method to parse the plist file contents string into a JavaScript object. This object represents the structure of the plist file as an array, object, or primitive values. Finally, we log the resulting JavaScript object to the console. When we run this code, it will output the contents of the example.plist file in a JavaScript object format. The format of the resulting JavaScript object depends on the structure of the original plist file. This demonstrates how plist.parse can be used to parse a plist file into a JavaScript object for further processing in JavaScript code.
230 231 232 233 234 235 236 237 238 239 240
}); const listIosDependencies = () => { const projectName = getProjectName(); const xmlText = fs.readFileSync(`${rootDir}/ios/Pods/Target Support Files/Pods-${projectName}/Pods-${projectName}-acknowledgements.plist`, 'utf8'); const xmlObj = plist.parse(xmlText); const podfileParser = new PodfileParser(); const libraries = xmlObj.PreferenceSpecifiers.filter(obj => { return !(['Acknowledgements', ''].includes(obj.Title) && !obj.License); }).map(lib => {
+ 4 other calls in file
129 130 131 132 133 134 135 136 137
if(!fs.existsSync(infoPath) || !fs.lstatSync(infoPath).isFile()) { console.error("Couldn't locate Info.plist."); return; } var infoPlist = plist.parse(fs.readFileSync(infoPath, 'utf8')); if(typeof infoPlist.UIBackgroundModes == "undefined") { infoPlist.UIBackgroundModes = []; }
+ 3 other calls in file
GitHub: loongson/npm-registry
143 144 145 146 147 148 149 150 151 152
return Object.assign(this.appPlist, propsOrFilename) } } async loadPlist (filename, propName) { const loadedPlist = plist.parse((await fs.readFile(filename)).toString()) if (propName) { this[propName] = loadedPlist } return loadedPlist
+ 4 other calls in file
GitHub: tahayunus/kepche
187 188 189 190 191 192 193 194 195 196
fs.writeFileSync(path.resolve(podFilePath), podFile); console.log('cordova-plugin-firebasex: Applied IOS_STRIP_DEBUG to Podfile'); } }, applyPluginVarsToPlists: function(pluginVariables, iosPlatform){ var googlePlist = plist.parse(fs.readFileSync(path.resolve(iosPlatform.dest), 'utf8')), appPlist = plist.parse(fs.readFileSync(path.resolve(iosPlatform.appPlist), 'utf8')), entitlementsDebugPlist = plist.parse(fs.readFileSync(path.resolve(iosPlatform.entitlementsDebugPlist), 'utf8')), entitlementsReleasePlist = plist.parse(fs.readFileSync(path.resolve(iosPlatform.entitlementsReleasePlist), 'utf8')), googlePlistModified = false,
+ 3 other calls in file
15 16 17 18 19 20 21 22 23 24 25
`https://amp-api.apps.apple.com/v1/catalog/US/apps/${item_id}?platform=web&fields=privacyDetails&l=en-us`; const getItemMeta = async (ipa) => { const zip = new StreamZip.async({ file: ipa }); const meta_plist = await zip.entryData('iTunesMetadata.plist'); const meta = plist.parse(meta_plist.toString()); await zip.close(); return { item_id: meta['itemId'], bundle_id: meta['softwareVersionBundleId'] }; }; const pause = (ms) => new Promise((res) => setTimeout(res, ms));
335 336 337 338 339 340 341 342 343 344
/* Updates the *-Info.plist file with data from config.xml by parsing to an xml string, then using the plist module to convert the data to a map. The config.xml data is then replaced or appended to the original plist file */ updateIosPlist: function (targetFile, configItems) { var infoPlist = plist.parse(fs.readFileSync(targetFile, 'utf-8')), tempInfoPlist; _.each(configItems, function (item) { var key = item.parent;
GitHub: ijah-derby/dr
180 181 182 183 184 185 186 187 188
fs.writeFileSync(podFilePath, podFile); console.log('cordova-plugin-firebasex: Applied IOS_STRIP_DEBUG to Podfile'); } }, applyPluginVarsToPlists: function(googlePlistPath, appPlistPath, pluginVariables){ var googlePlist = plist.parse(fs.readFileSync(googlePlistPath, 'utf8')), appPlist = plist.parse(fs.readFileSync(appPlistPath, 'utf8')), googlePlistModified = false, appPlistModified = false;
+ 3 other calls in file
plist.parse is the most popular function in plist (98 examples)