You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2025/08/04 16:32:49 UTC

(cordova-common) branch master updated: feat!: change resource-file behavior to support directory contents (#239)

This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-common.git


The following commit(s) were added to refs/heads/master by this push:
     new ad54a41  feat!: change resource-file behavior to support directory contents (#239)
ad54a41 is described below

commit ad54a418653ccd7c61a355a56f4144298258ff46
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Tue Aug 5 01:32:44 2025 +0900

    feat!: change resource-file behavior to support directory contents (#239)
---
 spec/FileUpdater.spec.js | 9 ++++-----
 src/FileUpdater.js       | 6 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/spec/FileUpdater.spec.js b/spec/FileUpdater.spec.js
index 3e8d74b..0800733 100644
--- a/spec/FileUpdater.spec.js
+++ b/spec/FileUpdater.spec.js
@@ -180,9 +180,9 @@ describe('FileUpdater class', function () {
             const updated = FileUpdater.updatePathWithStats(
                 testSourceDir, mockDirStats(), testTargetDir, null);
             expect(updated).toBe(true);
-            expect(mockFs.mkdirPaths.length).toBe(1);
+            expect(mockFs.cpPaths.length).toBe(1);
             expect(mockFs.rmPaths.length).toBe(0);
-            expect(mockFs.mkdirPaths[0]).toBe(testTargetDir);
+            expect(mockFs.cpPaths[0]).toEqual([testSourceDir, testTargetDir]);
         });
 
         it('Test 003 : should remove a directory that exists at target and not at source', function () {
@@ -275,11 +275,10 @@ describe('FileUpdater class', function () {
             const updated = FileUpdater.updatePathWithStats(
                 testSourceDir, mockDirStats(), testTargetDir, mockFileStats(now));
             expect(updated).toBe(true);
-            expect(mockFs.cpPaths.length).toBe(0);
+            expect(mockFs.cpPaths.length).toBe(1);
             expect(mockFs.rmPaths.length).toBe(1);
-            expect(mockFs.mkdirPaths.length).toBe(1);
             expect(mockFs.rmPaths[0]).toBe(testTargetDir);
-            expect(mockFs.mkdirPaths[0]).toBe(testTargetDir);
+            expect(mockFs.cpPaths[0]).toEqual([testSourceDir, testTargetDir]);
         });
 
         it('Test 013 : should remove and copy when source is a file and target is a directory', function () {
diff --git a/src/FileUpdater.js b/src/FileUpdater.js
index d4b6d61..1b95002 100644
--- a/src/FileUpdater.js
+++ b/src/FileUpdater.js
@@ -81,9 +81,9 @@ function updatePathWithStats (sourcePath, sourceStats, targetPath, targetStats,
     }
 
     if (sourceStats.isDirectory() && !targetStats) {
-        // The target directory does not exist, so we create it.
-        log(`mkdir ${targetPath}`);
-        fs.mkdirSync(targetFullPath, { recursive: true });
+        // The target directory does not exist, so recursive copy to create it and its contents.
+        log(`cpSync ${targetPath}`);
+        fs.cpSync(path.join(rootDir, sourcePath), targetFullPath, { recursive: true });
         return true;
     }
 


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