Repository: cordova-lib
Updated Branches:
  refs/heads/master 0c6f88d2b -> e810685ce


CB-11412 template support for www folders

 This closes #458


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/e810685c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/e810685c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/e810685c

Branch: refs/heads/master
Commit: e810685ce42a6615d62117f026316c9931ad8707
Parents: 0c6f88d
Author: carynbear <[email protected]>
Authored: Fri Jun 24 14:22:17 2016 -0700
Committer: Steve Gill <[email protected]>
Committed: Mon Jun 27 17:03:37 2016 -0700

----------------------------------------------------------------------
 cordova-lib/spec-cordova/create.spec.js | 23 +++++++++++++++++
 cordova-lib/src/cordova/create.js       | 37 +++++++++++++++++-----------
 2 files changed, 45 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e810685c/cordova-lib/spec-cordova/create.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/create.spec.js 
b/cordova-lib/spec-cordova/create.spec.js
index 8d57e10..e6f6a81 100644
--- a/cordova-lib/spec-cordova/create.spec.js
+++ b/cordova-lib/spec-cordova/create.spec.js
@@ -326,5 +326,28 @@ describe('create end-to-end', function() {
             .fin(done);
     });
 
+    it('should successfully run with www folder as the template', 
function(done) {
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 
'config_in_www', 'www'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                project = project + '3';
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkConfigXml)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
+
 
 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e810685c/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js 
b/cordova-lib/src/cordova/create.js
index da22755..d01d462 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -323,7 +323,8 @@ function ifNotCopied(src, dst) {
 
 /**
  * Copies template files, and directories into a Cordova project directory.
- * If the template exists in a subdirectory everything is copied. 
+ * If the template is a www folder, the www folder is simply copied
+ * Otherwise if the template exists in a subdirectory everything is copied
  * Otherwise package.json, RELEASENOTES.md, .git, NOTICE, LICENSE, COPYRIGHT, 
and .npmignore are not copied over.
  * A template directory, and project directory must be passed.
  * templateDir - Template directory
@@ -331,20 +332,26 @@ function ifNotCopied(src, dst) {
  * isSubDir - boolean is true if template has subdirectory structure (see code 
around line 229)
  */
 function copyTemplateFiles(templateDir, projectDir, isSubDir) {
-    var templateFiles;      // Current file
-    templateFiles = fs.readdirSync(templateDir);
-    // Remove directories, and files that are unwanted
-    if (!isSubDir) {
-        templateFiles = templateFiles.filter(
-            function (value) {
-                return !(value === 'package.json' || value === 
'RELEASENOTES.md' || value === '.git' || value === 'NOTICE'||
-                value === 'LICENSE' || value === 'COPYRIGHT' || value === 
'.npmignore');
-            }
-        );
-    }
-    // Copy each template file after filter
-    for (var i = 0; i < templateFiles.length; i++) {
-        var copyPath = path.resolve(templateDir, templateFiles[i]);
+    var copyPath;
+    // if template is a www dir
+    if (path.basename(templateDir) === 'www') {
+        copyPath = path.resolve(templateDir);
         shell.cp('-R', copyPath, projectDir);
+    } else {
+        var templateFiles;      // Current file
+        templateFiles = fs.readdirSync(templateDir);
+        // Remove directories, and files that are unwanted
+        if (!isSubDir) {
+            var excludes = ['package.json', 'RELEASENOTES.md' , '.git', 
'NOTICE', 'LICENSE', 'COPYRIGHT', '.npmignore'];
+            templateFiles = templateFiles.filter( function (value) { 
+                return excludes.indexOf(value) < 0; 
+            }); 
+        }
+        // Copy each template file after filter
+        for (var i = 0; i < templateFiles.length; i++) {
+            copyPath = path.resolve(templateDir, templateFiles[i]);
+            shell.cp('-R', copyPath, projectDir);
+        }
     }
+    
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to