cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-13614) Asset tag create only works if file is targeted to root directory
Date Wed, 06 Dec 2017 06:45:00 GMT

    [ https://issues.apache.org/jira/browse/CB-13614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16279739#comment-16279739
] 

ASF GitHub Bot commented on CB-13614:
-------------------------------------

purplecabbage closed pull request #49: CB-13614: (browser) Fix asset copy bug.
URL: https://github.com/apache/cordova-browser/pull/49
 
 
   

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 3e12c25..da1be3f 100644
--- a/bin/template/cordova/browser_handler.js
+++ b/bin/template/cordova/browser_handler.js
@@ -120,6 +120,9 @@ module.exports = {
             if (fs.statSync(src).isDirectory()) {
                 shell.cp('-Rf', src + '/*', dest);
             } else {
+                if (path.parse(asset.target).dir !== '') {
+                    shell.mkdir('-p', path.parse(dest).dir);
+                }
                 shell.cp('-f', src, dest);
             }
         },
diff --git a/spec/browser_handler.spec.js b/spec/browser_handler.spec.js
index 70a0682..1654b75 100644
--- a/spec/browser_handler.spec.js
+++ b/spec/browser_handler.spec.js
@@ -24,10 +24,10 @@ var path = require('path');
 
 describe('Asset install tests', function () {
     var fsstatMock;
-    var asset = { itemType: 'asset', src: 'someSrc/ServiceWorker.js', target: 'ServiceWorker.js'
};
+    var asset = { itemType: 'asset', src: path.join('someSrc', 'ServiceWorker.js'), target:
'ServiceWorker.js' };
+    var assetWithPath = { itemType: 'asset', src: path.join('someSrc', 'reformat.js'), target:
path.join('js', 'deepdown', 'reformat.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');
@@ -40,8 +40,9 @@ describe('Asset install tests', function () {
         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 () {
+    it('if src is not a directory and asset has no path, should be called with cp, -f', function
() {
         var cp = spyOn(shell, 'cp').and.returnValue('-f');
+        var mkdir = spyOn(shell, 'mkdir');
         fsstatMock = {
             isDirectory: function () {
                 return false;
@@ -49,6 +50,20 @@ describe('Asset install tests', function () {
         };
         spyOn(fs, 'statSync').and.returnValue(fsstatMock);
         browser_handler.asset.install(asset, plugin_dir, wwwDest);
-        expect(cp).toHaveBeenCalledWith('-f', cpPath, path.join('dest', asset.target));
+        expect(mkdir).not.toHaveBeenCalled();
+        expect(cp).toHaveBeenCalledWith('-f', path.join('pluginDir', 'someSrc', 'ServiceWorker.js'),
path.join('dest', 'ServiceWorker.js'));
+    });
+    it('if src is not a directory and asset has a path, should be called with cp, -f', function
() {
+        var cp = spyOn(shell, 'cp').and.returnValue('-f');
+        var mkdir = spyOn(shell, 'mkdir');
+        fsstatMock = {
+            isDirectory: function () {
+                return false;
+            }
+        };
+        spyOn(fs, 'statSync').and.returnValue(fsstatMock);
+        browser_handler.asset.install(assetWithPath, plugin_dir, wwwDest);
+        expect(mkdir).toHaveBeenCalledWith('-p', path.join('dest', 'js', 'deepdown'));
+        expect(cp).toHaveBeenCalledWith('-f', path.join('pluginDir', 'someSrc', 'reformat.js'),
path.join('dest', 'js', 'deepdown', 'reformat.js'));
     });
 });


 

----------------------------------------------------------------
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:
users@infra.apache.org


> Asset tag create only works if file is targeted to root directory
> -----------------------------------------------------------------
>
>                 Key: CB-13614
>                 URL: https://issues.apache.org/jira/browse/CB-13614
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-browser
>    Affects Versions: 5.0.1
>            Reporter: George Campbell
>            Assignee: Jesse MacFadyen
>
> Inside a plugin.xml file, 
> <asset src="www/style/inappbrowser.css" target="style/inappbrowser.css"/>
> results in:
> cp: copyFileSync: could not write to dest file (code=ENOENT):/Users/campbelg/IdeaProjects/wms-circ-app/platforms/browser/platform_www/style/inappbrowser.css
> Related to CB-13562, which fixed the case of an asset file whose target was the root
directory. This bug is for assets whose target contains a directory.
> The expected behavior is described by the plugin.xml documentation:
> https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#asset



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message