-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve vscode extension handling of relative paths
- Loading branch information
1 parent
de78f6c
commit 8ae6c32
Showing
6 changed files
with
119 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { parse_ts_imports } from 'windmill-parser-wasm-ts' | ||
|
||
export function parseTypescriptDeps(code: string): string[] { | ||
let r = JSON.parse(parse_ts_imports(code)) | ||
if (r.error) { | ||
console.error(r.error) | ||
return [] | ||
} else { | ||
return r.imports | ||
} | ||
} | ||
|
||
export function isTypescriptRelativePath(d: string) { | ||
return ( | ||
d.startsWith('./') || | ||
d.startsWith('../') || | ||
d.startsWith('/') || | ||
d.startsWith('.../') || | ||
d.startsWith('/') | ||
) | ||
} | ||
|
||
export function approximateFindPythonRelativePath(code: string) { | ||
// Define the regular expression for finding relative imports | ||
const regex = /^\s*from\s+(\.+)\w*\s+import\s+.+$/gm | ||
|
||
// Use match to find all matches in the code | ||
const matches = code.match(regex) | ||
return [...(matches?.entries() ?? [])] || [] | ||
} |