[
https://issues.apache.org/jira/browse/CB-13562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16249908#comment-16249908
]
ASF GitHub Bot commented on CB-13562:
-------------------------------------
audreyso closed pull request #48: CB-13562 : fixed asset tag when adding push
plugin to browser
URL: https://github.com/apache/cordova-browser/pull/48
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/bin/template/cordova/browser_handler.js
b/bin/template/cordova/browser_handler.js
index 6e732c7..3e12c25 100644
--- a/bin/template/cordova/browser_handler.js
+++ b/bin/template/cordova/browser_handler.js
@@ -115,12 +115,13 @@ module.exports = {
asset: {
install: function (asset, plugin_dir, wwwDest) {
var src = path.join(plugin_dir, asset.src);
- if (fs.statSync(src).isDirectory()) {
- src = path.join(src, '*');
- }
var dest = path.join(wwwDest, asset.target);
- shell.cp('-rf', src, dest);
+ if (fs.statSync(src).isDirectory()) {
+ shell.cp('-Rf', src + '/*', dest);
+ } else {
+ shell.cp('-f', src, dest);
+ }
},
uninstall: function (asset, wwwDest, plugin_id) {
shell.rm('-rf', path.join(wwwDest, asset.target));
diff --git a/spec/browser_handler.spec.js b/spec/browser_handler.spec.js
new file mode 100644
index 0000000..70a0682
--- /dev/null
+++ b/spec/browser_handler.spec.js
@@ -0,0 +1,54 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var browser_handler = require('../bin/template/cordova/browser_handler');
+var shell = require('shelljs');
+var fs = require('fs');
+var path = require('path');
+
+describe('Asset install tests', function () {
+ var fsstatMock;
+ var asset = { itemType: 'asset', src: 'someSrc/ServiceWorker.js', target:
'ServiceWorker.js' };
+ var plugin_dir = 'pluginDir';
+ var wwwDest = 'dest';
+ var cpPath = path.join(plugin_dir, asset.src);
+
+ it('if src is a directory, should be called with cp, -Rf', function () {
+ var cp = spyOn(shell, 'cp').and.returnValue('-Rf');
+ fsstatMock = {
+ isDirectory: function () {
+ return true;
+ }
+ };
+ spyOn(fs, 'statSync').and.returnValue(fsstatMock);
+ browser_handler.asset.install(asset, plugin_dir, wwwDest);
+ expect(cp).toHaveBeenCalledWith('-Rf', jasmine.any(String),
path.join('dest', asset.target));
+ });
+ it('if src is not a directory, should be called with cp, -f', function () {
+ var cp = spyOn(shell, 'cp').and.returnValue('-f');
+ fsstatMock = {
+ isDirectory: function () {
+ return false;
+ }
+ };
+ spyOn(fs, 'statSync').and.returnValue(fsstatMock);
+ browser_handler.asset.install(asset, plugin_dir, wwwDest);
+ expect(cp).toHaveBeenCalledWith('-f', cpPath, path.join('dest',
asset.target));
+ });
+});
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Asset tag creates a directory with same name of targeted file
> -------------------------------------------------------------
>
> Key: CB-13562
> URL: https://issues.apache.org/jira/browse/CB-13562
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-browser
> Affects Versions: 5.0.1
> Reporter: Simon MacDonald
> Assignee: Jesse MacFadyen
> Labels: reproduced, triaged
>
> Asset tag appears to be broken in the browser platform. According to the docs
> at http://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#asset when
> you add an asset tag like:
> {code:xml}
> <asset src="www/foo.js" target="foo.js" />
> {code}
> it should copy www/foo.js to platforms/browser/www/foo.js but instead it
> creates a subdirectory called foo.js and the full path to the file is
> platforms/browser/www/foo.js/foo.js.
> If you want to duplicate this issue please create a new project then:
> cordova platform add [email protected]
> cordova plugin add phonegap-plugin-push
> cordova build browser
> then you will see that
> platforms/browser/www/ServiceWorker.js/ServiceWorker.js exists when it should
> be platforms/browser/www/ServiceWorker.js.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]