Skip to content

Commit e01525a

Browse files
committed
Move shouldExcludeFromSync to its own module and use path.basename
1 parent 9348670 commit e01525a

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎apps/cli/lib/sync-file-tree.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import fs from 'fs';
22
import nodePath from 'path';
33
import { createDeployIgnoreFilter } from '@studio/common/lib/deploy-ignore';
44
import { SYNC_IGNORE_DEFAULTS } from '@studio/common/lib/sync/constants';
5-
import { shouldExcludeFromSync, shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
5+
import { shouldExcludeFromSync } from '@studio/common/lib/sync/exclude-from-sync';
6+
import { shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
67
import type { RawDirectoryEntry } from '@studio/common/types/sync-tree';
78
import type { Ignore } from 'ignore';
89

‎apps/studio/src/ipc-handlers.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ import {
5757
updateSharedConfig,
5858
} from '@studio/common/lib/shared-config';
5959
import { SYNC_IGNORE_DEFAULTS } from '@studio/common/lib/sync/constants';
60-
import { shouldExcludeFromSync, shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
60+
import { shouldExcludeFromSync } from '@studio/common/lib/sync/exclude-from-sync';
61+
import { shouldLimitDepth } from '@studio/common/lib/sync/tree-utils';
6162
import { isWordPressDevVersion } from '@studio/common/lib/wordpress-version-utils';
6263
import { __, sprintf, LocaleData, defaultI18n } from '@wordpress/i18n';
6364
import {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import path from 'path';
2+
import type { Ignore } from 'ignore';
3+
4+
export const shouldExcludeFromSync = ( relativePath: string, deployIgnore: Ignore ): boolean => {
5+
const itemName = path.basename( relativePath );
6+
// Hide dotfiles from the sync tree UI. The remote import drops root
7+
// dotfiles on its own, so this keeps the tree aligned with what ends
8+
// up on the remote. The tree does not render deeper than plugin and
9+
// theme directories, so nested dotfiles aren't a concern here.
10+
if ( itemName.startsWith( '.' ) ) {
11+
return true;
12+
}
13+
return deployIgnore.ignores( relativePath );
14+
};

‎tools/common/lib/sync/tree-utils.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
import type { SyncOption } from '@studio/common/types/sync';
2-
import type { Ignore } from 'ignore';
3-
4-
export const shouldExcludeFromSync = ( relativePath: string, deployIgnore: Ignore ): boolean => {
5-
const itemName = relativePath.split( '/' ).pop() || '';
6-
// Hide dotfiles from the sync tree UI. The remote import drops root
7-
// dotfiles on its own, so this keeps the tree aligned with what ends
8-
// up on the remote. The tree does not render deeper than plugin and
9-
// theme directories, so nested dotfiles aren't a concern here.
10-
if ( itemName.startsWith( '.' ) ) {
11-
return true;
12-
}
13-
return deployIgnore.ignores( relativePath );
14-
};
152

163
export const shouldLimitDepth = ( relativePath: string ): boolean => {
174
const normalizedPath = relativePath.replace( /^wp-content\//, '' );

0 commit comments

Comments
 (0)