Ignore .git & node_modules in preview archive - #1367
Conversation
Sync ignores .git and node_modules, but preview does not. This discrepancy was causing a failure to create the archive, due to the following error: could not open for reading: .git/fsmonitor--daemon.ipc
sejas
left a comment
There was a problem hiding this comment.
@grgar, Thank you for creating this PR. I tested it and confirm that it works as expected, excluding the .git and node_modules folders. This will speed up the process of uploading the zip and also fix your issue.
I tried to push the changes to format the code, but I don't have write access. Could you either apply the changes to your branch or grant edit access to maintainers?
Co-authored-by: Antonio Sejas <antonio@sejas.es>
|
Thanks @sejas, apologies I've applied your suggestion thank you. I also don't appear to have that option to grant edit access unfortunately edit: it appears to be because I put forks in a separate organisation to keep my account tidy and https://github.com/orgs/community/discussions/5634 — sorry I didn't realise the issue that causes |
|
I see the unit tests are failing. @grgar, could you apply this diff to fix the tests? diff --git a/cli/lib/tests/archive.test.ts b/cli/lib/tests/archive.test.ts
index 15f2c1db..bb59ac32 100644
--- a/cli/lib/tests/archive.test.ts
+++ b/cli/lib/tests/archive.test.ts
@@ -51,7 +51,11 @@ describe( 'Archive Module', () => {
expect( archiver ).toHaveBeenCalledWith( 'zip', { zlib: { level: 9 } } );
expect( mockArchiver.pipe ).toHaveBeenCalledWith( mockWriteStream );
expect( path.join ).toHaveBeenCalledWith( mockSiteFolder, 'wp-content' );
- expect( mockArchiver.directory ).toHaveBeenCalledWith( mockWpContentPath, 'wp-content' );
+ expect( mockArchiver.directory ).toHaveBeenCalledWith(
+ mockWpContentPath,
+ 'wp-content',
+ expect.any( Function )
+ );
expect( path.join ).toHaveBeenCalledWith( mockSiteFolder, 'wp-config.php' );
expect( fs.existsSync ).toHaveBeenCalledWith( mockWpConfigPath );
expect( mockArchiver.file ).not.toHaveBeenCalled();
|
Co-authored-by: Antonio Sejas <antonio@sejas.es>
|
Thanks @sejas I've applied the patch and invited you to the fork if you want to push anything, sorry again about that issue I won't use an org in the future until GitHub fix the issue! |
|
Thanks @grgar ! I triggered builds for those changes. |

Export ignores .git and node_modules:
studio/src/lib/import-export/export/exporters/default-exporter.ts
Lines 233 to 234 in 0c0f64d
Preview did not, causing a failure to create the archive for me due to the following error:
Proposed Changes
.gitandnode_modulesin wp-content.Testing Instructions
git initinside wp-contentgit config core.fsmonitor trueif not already set globally and trigger the ipc file creation (e.g. rungit status)Pre-merge Checklist