You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/12/19 01:33:18 UTC

[GitHub] erisu closed pull request #607: Copy node_modules if the directory exists

erisu closed pull request #607: Copy node_modules if the directory exists
URL: https://github.com/apache/cordova-android/pull/607
 
 
   

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/create b/bin/create
index 0d841e185..fbab2429e 100755
--- a/bin/create
+++ b/bin/create
@@ -50,8 +50,7 @@ if (argv['activity-name']) config.setName(argv['activity-name']);
 var options = {
     link: argv.link || argv.shared,
     customTemplate: argv.argv.remain[3],
-    activityName: argv['activity-name'],
-    copyPlatformNodeModules: true
+    activityName: argv['activity-name']
 };
 
 require('./templates/cordova/loggingHelper').adjustLoggerLevel(argv);
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 2b5a65ecd..d6451a756 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -160,7 +160,7 @@ function copyBuildRules (projectPath, isLegacy) {
     }
 }
 
-function copyScripts (projectPath, options) {
+function copyScripts (projectPath) {
     var bin = path.join(ROOT, 'bin');
     var srcScriptsDir = path.join(bin, 'templates', 'cordova');
     var destScriptsDir = path.join(projectPath, 'cordova');
@@ -168,7 +168,10 @@ function copyScripts (projectPath, options) {
     shell.rm('-rf', destScriptsDir);
     // Copy in the new ones.
     shell.cp('-r', srcScriptsDir, projectPath);
-    if (options.copyPlatformNodeModules) shell.cp('-r', path.join(ROOT, 'node_modules'), destScriptsDir);
+
+    let nodeModulesDir = path.join(ROOT, 'node_modules');
+    if (fs.existsSync(nodeModulesDir)) shell.cp('-r', nodeModulesDir, destScriptsDir);
+
     shell.cp(path.join(bin, 'check_reqs*'), destScriptsDir);
     shell.cp(path.join(bin, 'android_sdk_version*'), destScriptsDir);
     var check_reqs = path.join(destScriptsDir, 'check_reqs');
@@ -324,7 +327,7 @@ exports.create = function (project_path, config, options, events) {
                 var manifest_path = path.join(app_path, 'AndroidManifest.xml');
                 manifest.write(manifest_path);
 
-                exports.copyScripts(project_path, options);
+                exports.copyScripts(project_path);
                 exports.copyBuildRules(project_path);
             });
             // Link it to local android install.
diff --git a/spec/unit/create.spec.js b/spec/unit/create.spec.js
index 2acaa8b3b..ac7026b35 100644
--- a/spec/unit/create.spec.js
+++ b/spec/unit/create.spec.js
@@ -259,7 +259,7 @@ describe('create', function () {
             });
             it('should copy template scripts into generated project', function (done) {
                 create.create(project_path, config_mock, {}, events_mock).then(function () {
-                    expect(create.copyScripts).toHaveBeenCalledWith(project_path, {});
+                    expect(create.copyScripts).toHaveBeenCalledWith(project_path);
                 }).fail(fail).done(done);
             });
             it('should copy build rules / gradle files into generated project', function (done) {


 

----------------------------------------------------------------
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


With regards,
Apache Git Services

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