Skip to content

Commit 4cd7c63

Browse files
committed
fix(namespace-error): Remove not needed android namespace
fixes #1
1 parent 906d34a commit 4cd7c63

File tree

6 files changed

+132
-4
lines changed

6 files changed

+132
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
.DS_Store
3+
reports

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sudo: required
2+
dist: trusty
3+
language: node_js
4+
node_js:
5+
- "4"
6+
- "5"
7+
- "6"
8+
- "7"
9+
- "stable"
10+
env:
11+
- NPM_VERSION=4
12+
- NPM_VERSION=3
13+
before_install:
14+
- npm install -g npm@$NPM_VERSION
15+
before_script:
16+
- npm install
17+
script:
18+
- npm test

index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
'use strict';
22

3+
const path = require('path');
4+
const fs = require('fs');
35
const xmlpoke = require('xmlpoke');
46
const packageJSON = require(process.cwd() + '/package.json');
57

6-
console.log(process.cwd())
7-
88
function configpluginxml(inFile) {
99
const defaultFile = 'plugin.xml';
1010
const packageFile = 'package.json';
1111
const file = inFile || defaultFile;
1212

13+
console.log(file);
14+
1315
function poke(cb) {
16+
let xmlContent = fs.readFileSync(path.resolve(file), 'utf8');
1417
// https://github.com/mikeobrien/node-xmlpoke/issues/3
15-
xmlpoke(file, xml => cb(xml.addNamespace('p', 'http://apache.org/cordova/ns/plugins/1.0')));
18+
let updatedContent = xmlpoke(xmlContent, xml => cb(xml.addNamespace('p', 'http://apache.org/cordova/ns/plugins/1.0')));
19+
updatedContent = updatedContent.replace(' xmlns:android=""', '');
20+
fs.writeFileSync(path.resolve(file), updatedContent, 'utf8');
1621
}
1722

1823
function set(xpath, val) {

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"clean": "rimraf node_modules",
99
"postclean": "npm i",
1010
"build": "exit 0",
11-
"test": "exit 0",
11+
"test": "jasmine-node test --junitreport",
1212
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
1313
"changelog:add": "git add CHANGELOG.md && git commit -m 'chore(changelog): Updated CHANGELOG.md'",
1414
"release:pre": "npm run clean && npm run build",
@@ -61,6 +61,11 @@
6161
},
6262
"devDependencies": {
6363
"conventional-changelog-cli": "1.3.1",
64+
"istanbul": "0.4.5",
65+
"istanbul-coveralls": "1.0.3",
66+
"jasmine-node": "1.14.5",
67+
"jscoverage": "0.6.0",
68+
"nodeunit": "0.11.0",
6469
"rimraf": "2.6.1"
6570
}
6671
}

test/index.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var configPluginXml = require('../index'),
2+
path = require('path'),
3+
fs = require('fs');
4+
5+
describe('api', function () {
6+
7+
it('should replace', function (done) {
8+
configPluginXml(path.resolve(__dirname, 'test.xml')).setVersion('0.1.0');
9+
setTimeout(function () {
10+
var testXml = fs.readFileSync(path.resolve(__dirname, 'test.xml'), 'utf8');
11+
expect(testXml).not.toContain('<activity xmlns:android=""');
12+
done();
13+
}, 1000);
14+
});
15+
});

test/test.xml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
4+
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-test" version="0.1.0">
5+
6+
<name>test</name>
7+
<description>Scans Barcodes</description>
8+
<license>MIT</license>
9+
10+
<engines>
11+
<engine name="cordova" version=">=3.0.0"/>
12+
</engines>
13+
14+
15+
<!-- ios -->
16+
<platform name="ios">
17+
<!-- Cordova >= 2.8 -->
18+
<config-file target="config.xml" parent="/*">
19+
<feature name="BarcodeScanner">
20+
<param name="ios-package" value="CDVBarcodeScanner"/>
21+
</feature>
22+
</config-file>
23+
24+
<resource-file src="src/ios/scannerOverlay.xib"/>
25+
26+
<header-file src="src/ios/zxing-all-in-one.h"/>
27+
28+
<source-file src="src/ios/CDVBarcodeScanner.mm" compiler-flags="-fno-objc-arc"/>
29+
<source-file src="src/ios/zxing-all-in-one.cpp"/>
30+
31+
<framework src="libiconv.dylib"/>
32+
<framework src="AVFoundation.framework"/>
33+
<framework src="AssetsLibrary.framework"/>
34+
<framework src="CoreVideo.framework"/>
35+
<framework src="QuartzCore.framework"/>
36+
</platform>
37+
38+
<!-- android -->
39+
<platform name="android">
40+
41+
<config-file target="AndroidManifest.xml" parent="/manifest/application">
42+
<activity android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden" android:exported="false">
43+
<intent-filter>
44+
<action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
45+
<category android:name="android.intent.category.DEFAULT"/>
46+
</intent-filter>
47+
</activity>
48+
</config-file>
49+
50+
</platform>
51+
52+
<platform name="windows8">
53+
<js-module src="src/windows8/BarcodeScannerProxy.js" name="BarcodeScannerProxy">
54+
<merges target=""/>
55+
</js-module>
56+
<config-file target="package.appxmanifest" parent="/Package/Capabilities">
57+
<DeviceCapability Name="webcam"/>
58+
</config-file>
59+
<framework src="src/windows8/lib/ZXing.winmd" custom="true"/>
60+
<framework src="src/windows8/lib/WinRTBarcodeReader.winmd" custom="true"/>
61+
</platform>
62+
63+
<!-- Windows Phone 8 -->
64+
<platform name="wp8">
65+
66+
<config-file target="config.xml" parent="/*">
67+
<feature name="BarcodeScanner">
68+
<param name="wp-package" value="BarcodeScanner"/>
69+
</feature>
70+
</config-file>
71+
72+
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
73+
<Capability Name="ID_CAP_ISV_CAMERA"/>
74+
</config-file>
75+
76+
<framework src="src/wp8/lib/zxing.wp8.0.dll" custom="true"/>
77+
78+
<source-file src="src/wp8/BarcodeScanner.cs"/>
79+
<source-file src="src/wp8/BarcodeScannerTask.cs"/>
80+
<source-file src="src/wp8/BarcodeScannerUI.xaml"/>
81+
<source-file src="src/wp8/BarcodeScannerUI.xaml.cs"/>
82+
83+
</platform>
84+
</plugin>

0 commit comments

Comments
 (0)