Skip to content

Commit

Permalink
Move json format functions to formatUtil (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Sep 15, 2024
1 parent 9bdb3c0 commit 347563a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/scripts/ui/menu/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { $el } from '../../ui'
import { api } from '../../api'
import { ComfyPopup } from '../components/popup'
import { createSpinner } from '../spinner'
import { ComfyWorkflow, trimJsonExt } from '../../workflows'
import { ComfyWorkflow } from '../../workflows'
import { ComfyAsyncDialog } from '../components/asyncDialog'
import { trimJsonExt } from '@/utils/formatUtil'
import type { ComfyApp } from '@/scripts/app'
import type { ComfyComponent } from '../components'

Expand Down
12 changes: 1 addition & 11 deletions src/scripts/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ import { ChangeTracker } from './changeTracker'
import { ComfyAsyncDialog } from './ui/components/asyncDialog'
import { getStorageValue, setStorageValue } from './utils'
import { LGraphCanvas, LGraph } from '@comfyorg/litegraph'

function appendJsonExt(path: string) {
if (!path.toLowerCase().endsWith('.json')) {
path += '.json'
}
return path
}

export function trimJsonExt(path: string) {
return path?.replace(/\.json$/, '')
}
import { appendJsonExt, trimJsonExt } from '@/utils/formatUtil'

export class ComfyWorkflowManager extends EventTarget {
executionStore: any = null
Expand Down
11 changes: 11 additions & 0 deletions src/utils/formatUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@ export function formatCamelCase(str: string): string {
// Join the words with spaces
return processedWords.join(' ')
}

export function appendJsonExt(path: string) {
if (!path.toLowerCase().endsWith('.json')) {
path += '.json'
}
return path
}

export function trimJsonExt(path: string) {
return path.replace(/\.json$/, '')
}

0 comments on commit 347563a

Please sign in to comment.