Skip to content

Commit fa54e1d

Browse files
Export: Exclude node_modules and .git paths from site export (#1264)
* Exclude `node_modules` from plugin directories during site export * Remove leftover code * Exclude node_modules and .git directories from file export in a simpler way
1 parent e9d504d commit fa54e1d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/lib/import-export/export/exporters/default-exporter.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,17 @@ export class DefaultExporter extends EventEmitter implements Exporter {
223223
return directoryContents.reduce< string[] >( ( files: string[], directoryContent ) => {
224224
const filePath = path.join( directoryContent.path, directoryContent.name );
225225
const relativePath = path.relative( this.options.site.path, filePath );
226+
227+
// Check for exact path exclusions
226228
const isExcluded = this.pathsToExclude.some( ( pathToExclude ) =>
227229
relativePath.startsWith( path.normalize( pathToExclude ) )
228230
);
229-
if ( isExcluded ) {
231+
232+
// Check for node_modules and .git directories anywhere
233+
const isNodeModulesDirectory = relativePath.includes( 'node_modules' );
234+
const isGitDirectory = relativePath.includes( '.git' );
235+
236+
if ( isExcluded || isNodeModulesDirectory || isGitDirectory ) {
230237
return files;
231238
}
232239
if ( directoryContent.isFile() ) {

0 commit comments

Comments
 (0)