Skip to content

Commit

Permalink
refactor: simplify findScript function logic ♻️
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 13, 2024
1 parent d79b532 commit 8496e20
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/vscode/src/fragmentcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,16 @@ export function activateFragmentCommands(state: ExtensionState) {
const findScript = (filename: vscode.Uri) => {
const fp = state.host.path.resolve(filename.fsPath)
const scripts = state.project.scripts.filter((p) => !!p.filename)
const script = scripts
.filter((p) => !!p.filename)
.find((p) => {
const sfp = scriptFile(p)
return sfp === fp
})
const script = scripts.find((p) => {
const sfp = scriptFile(p)
return sfp === fp
})

if (!script) {
state.output.appendLine(`requested script: ${fp}`)
state.output.appendLine(`fspath: ${filename.fsPath}`)
state.output.appendLine(`resolved: ${fp}`)
state.output.appendLine(
`project folder: ${state.host.projectFolder()}`
`projectfolder: ${state.host.projectFolder()}`
)
scripts.forEach((s) =>
state.output.appendLine(`- ${s.filename}\n ${scriptFile(s)}`)
Expand Down

0 comments on commit 8496e20

Please sign in to comment.