New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pluginstall

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pluginstall - npm Package Compare versions

Comparing version 0.3.9 to 0.4.0

test/equalNodes.js

2

package.json

@@ -5,3 +5,3 @@ {

"description": "install Cordova plugins",
"version": "0.3.9",
"version": "0.4.0",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -5,5 +5,8 @@ var fs = require('../util/fs'), // use existsSync in 0.6.x

et = require('elementtree'),
nCallbacks = require('../util/ncallbacks'),
asyncCopy = require('../util/asyncCopy'),
equalNodes = require('../util/equalNodes'),
getConfigChanges = require('../util/config-changes'),
assetsDir = 'assets/www', // relative path to project's web assets

@@ -19,2 +22,3 @@ sourceDir = 'src',

libFiles = platformTag.findall('./library-file'),
PACKAGE_NAME = packageName(config),

@@ -29,4 +33,3 @@ configChanges = getConfigChanges(platformTag),

if (fs.existsSync(path.resolve(config.projectPath, configFile))) {
// if so, add length to callbackCount
callbackCount += configChanges[configFile].length
callbackCount++;
} else {

@@ -83,24 +86,30 @@ delete configChanges[configFile];

// edit configuration files
Object.keys(configChanges).forEach(function (filename) {
var filepath = path.resolve(config.projectPath, filename),
xmlDoc = readAsETSync(filepath),
output;
configChanges[filename].forEach(function (configNode) {
var filepath = path.resolve(config.projectPath, filename),
xmlDoc = readAsETSync(filepath),
selector = configNode.attrib["parent"],
child = configNode.find('*');
var selector = configNode.attrib["parent"],
children = configNode.findall('*');
if (addToDoc(xmlDoc, child, selector)) {
fs.writeFile(filepath, xmlDoc.write(), function (err) {
if (err) endCallback(err);
endCallback();
});
} else {
endCallback('failed to add node to ' + filename);
if (!addToDoc(xmlDoc, children, selector)) {
endCallback('failed to add children to ' + filename);
}
});
output = xmlDoc.write();
output = output.replace(/\$PACKAGE_NAME/g, PACKAGE_NAME);
fs.writeFile(filepath, output, function (err) {
if (err) endCallback(err);
endCallback();
});
});
}
// adds node to doc at selector
function addToDoc(doc, node, selector) {
// adds nodes to doc at selector
function addToDoc(doc, nodes, selector) {
var ROOT = /^\/([^\/]*)/,

@@ -128,6 +137,29 @@ ABSOLUTE = /^\/([^\/]*)\/(.*)/,

parent.append(node);
nodes.forEach(function (node) {
// check if child is unique first
if (uniqueChild(node, parent)) {
parent.append(node);
}
});
return true;
}
function uniqueChild(node, parent) {
var matchingKids = parent.findall(node.tag),
i = 0;
if (matchingKids.length == 0) {
return true;
} else {
for (i; i < matchingKids.length; i++) {
if (equalNodes(node, matchingKids[i])) {
return false;
}
}
return true;
}
}
function readAsETSync(filename) {

@@ -148,1 +180,8 @@ var contents = fs.readFileSync(filename, 'utf-8');

}
function packageName(config) {
var mDoc = readAsETSync(
path.resolve(config.projectPath, 'AndroidManifest.xml'));
return mDoc._root.attrib['package'];
}

@@ -31,3 +31,3 @@ # Pluginstall

Currently support the June 8 revision.
Currently support the August 16 revision, more or less.

@@ -34,0 +34,0 @@ ## License

@@ -109,7 +109,7 @@ // Test installation on Cordova 2 project

exports['should add ChildBrowser to config.xml'] = function (test) {
/* TODO all this
android.installPlugin(config, plugin, function (err) {
var pluginsTxt = fs.readFileSync('test/project/res/xml/plugins.xml', 'utf-8'),
var pluginsTxt = fs.readFileSync('test/project/android_two/res/xml/config.xml',
'utf-8'),
pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
expected = 'plugin[@name="ChildBrowser"]' +
expected = 'plugins/plugin[@name="ChildBrowser"]' +
'[@value="com.phonegap.plugins.childBrowser.ChildBrowser"]';

@@ -120,6 +120,3 @@

})
*/
test.done();
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc