Skip to content

Commit

Permalink
chore: rename useWatchDirectory to useFileSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
TimMikeladze committed Sep 6, 2023
1 parent 5b5461b commit 11001e8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ pnpm add use-file-system

```tsx
import React from 'react';
import { commonFilters, useWatchDirectory } from 'use-file-system';
import { commonFilters, useFileSystem } from 'use-file-system';

export const Example = () => {
const { onDirectorySelection, files } = useWatchDirectory({
const { onDirectorySelection, files } = useFileSystem({
filters: commonFilters, // filters out .gitignore paths and output paths like node_modules or dist, etc
onFilesAdded: (newFiles, previousFiles) => {
console.log('onFilesAdded', newFiles, previousFiles);
Expand Down Expand Up @@ -93,7 +93,7 @@ export const Example = () => {
- [distFilter](#gear-distfilter)
- [miscFilter](#gear-miscfilter)
- [processDirectory](#gear-processdirectory)
- [useWatchDirectory](#gear-usewatchdirectory)
- [useFileSystem](#gear-usefilesystem)

### :gear: gitFilter

Expand All @@ -119,11 +119,11 @@ export const Example = () => {
| ---------- | ---------- |
| `processDirectory` | `(directoryHandle: FileSystemDirectoryHandle, directoryPath: string, filters: Filter[], includeFiles: Map<string, FileSystemFileHandle>, ignoreFilePaths: Set<...>) => Promise<...>` |

### :gear: useWatchDirectory
### :gear: useFileSystem

| Function | Type |
| ---------- | ---------- |
| `useWatchDirectory` | `(props: UseFileHandlingHookProps) => { handles: Map<string, FileSystemFileHandle>; onDirectorySelection: () => Promise<void>; files: Map<...>; isProcessing: boolean; }` |
| `useFileSystem` | `(props: UseFileHandlingHookProps) => { handles: Map<string, FileSystemFileHandle>; onDirectorySelection: () => Promise<void>; files: Map<...>; isProcessing: boolean; }` |


## :wrench: Constants
Expand Down
3 changes: 0 additions & 3 deletions src/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ export const distFilter: FilterFn = async () => {
if (filepath.includes(`/node_modules/`)) {
return true;
}
if (filepath.includes(`/node_modules/`)) {
return true;
}
if (filepath.includes(`/.next/`)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './filters';
export * from './processDirectory';
export * from './useWatchDirectory';
export * from './useFileSystem';
4 changes: 1 addition & 3 deletions src/stories/Example.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ const Template: StoryFn<typeof Example> = () => <Example />;

export const Primary = Template.bind({});

Primary.args = {
text: 'Clicked this many times:',
};
Primary.args = {};
4 changes: 2 additions & 2 deletions src/stories/Example.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { action } from '@storybook/addon-actions';
import { commonFilters, useWatchDirectory } from '..';
import { commonFilters, useFileSystem } from '..';

export const Example = () => {
const { onDirectorySelection, files } = useWatchDirectory({
const { onDirectorySelection, files } = useFileSystem({
filters: commonFilters,
onFilesAdded: (newFiles, previousFiles) => {
console.log('onFilesAdded', newFiles, previousFiles);
Expand Down
2 changes: 1 addition & 1 deletion src/useWatchDirectory.tsx → src/useFileSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface UseFileHandlingHookProps {

const DEFAULT_POLL_INTERVAL = 500;

export const useWatchDirectory = (props: UseFileHandlingHookProps) => {
export const useFileSystem = (props: UseFileHandlingHookProps) => {
const {
onFilesAdded: onAddFile,
onFilesChanged: onChangeFile,
Expand Down

0 comments on commit 11001e8

Please sign in to comment.