Parse and edit the config.xml file of a cordova project.
npm install --save cordova-config
const Config = require('cordova-config');
// Load and parse the config.xml
const config = new Config('config.xml');
config.setName('My application');
config.setDescription('This is the description of my application');
config.setAuthor('Sam Verschueren', '[email protected]', 'https://github.com/SamVerschueren');
// Write the config file
config.writeSync();
Loads and parses the file.
Required
Type: string
The path to the config.xml
file.
Sets the
<name>name</name>
tag in the xml file.
Required
Type: string
The name of the application.
Sets a
<tag>text</tag>
tag in the xml file.
Required
Type: string
The name of the element.
Type: string
The element text.
Type: object
The element attributes
Sets the
<description>description</description>
tag in the xml file.
Required
Type: string
The description of the application.
Sets the
<author email="email" href="website">name</author>
tag in the xml file.
Required
Type: string
The name of the author.
Type: string
The email address of the email.
Type: string
The website of the author.
Sets the version attribute of the
widget
tag in the xml file.
Required
Type: string
The version in the format x.y.z
.
Sets the android-versionCode attribute of the
widget
tag in the xml file.
Required
Type: number
The Android version code.
Sets the Android package name of the config file.
Required
Type: string
The android package name.
Sets the ios-CFBundleVersion attribute of the
widget
tag in the xml file.
Required
Type: string
The version in the format x.y.z
.
Sets the iOS CFBundleIdentifier of the config file.
Required
Type: string
The iOS CFBundleIdentifier
.
Adds a
<preference name="name" value="value" />
tag to the xml file.
Required
Type: string
The name of the preference tag.
Required
Type: string|boolean
The value of the preference.
Removes all the
<access />
tags in the xml file.
Removes the
<access />
tag with the origin equal to the parameter.
Required
Type: string
The origin of the access tag you want to remove.
Adds an
<access />
tag to the xml file.
Required
Type: string
The origin of the access tag.
Type: object
A map with extra attributes that will be added to the access tag.
Sets the ID of the config file.
Required
Type: string
The id of the widget tag.
Adds the hook with type and src. see Apache Cordova API Documentation for more info.
Required
Type: string
Cordova hook type. ex) 'after_build', 'after_compile', 'after_clean'
Required
Type: string
Src path of hook script
Adds a raw xml element to the root of the config file.
Required
Type: string
A raw xml element. You can only pass in one element with one root.
Writes the
config.xml
file async.
Resolves a promise when the file is written.
Writes the
config.xml
file synchronously.
- cordova-config-cli - CLI for this module
MIT © Sam Verschueren