mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 00:05:27 +00:00
fix: improve bun assistant for relative paths
This commit is contained in:
@@ -72,5 +72,11 @@ export const mapModuleNameToModule = (moduleSpecifier: string) => {
|
||||
}
|
||||
|
||||
export function isRelativePath(d: string) {
|
||||
return d.startsWith('./') || d.startsWith('../') || d.startsWith('/') || d.startsWith('.../')
|
||||
return (
|
||||
d.startsWith('./') ||
|
||||
d.startsWith('../') ||
|
||||
d.startsWith('/') ||
|
||||
d.startsWith('.../') ||
|
||||
d.startsWith('/')
|
||||
)
|
||||
}
|
||||
|
||||
@@ -114,15 +114,18 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
|
||||
const relativeDeps = depsToGet.filter((f) => isRelativePath(f.raw))
|
||||
relativeDeps.forEach(async (f) => {
|
||||
let path = f.raw.startsWith('/')
|
||||
? ''
|
||||
? f.raw
|
||||
: '/' + config.scriptPath + (f.raw.startsWith('../') ? '/../' : '/.') + f.raw
|
||||
let url = config.root + path
|
||||
console.log('fetching local file', url, f.raw)
|
||||
const res = await fetch(url)
|
||||
if (res.ok) {
|
||||
config.delegate.localFile?.(await res.text(), f.raw)
|
||||
}
|
||||
})
|
||||
}
|
||||
depsToGet.forEach((dep) => moduleMap.set(dep.raw, { state: 'loading' }))
|
||||
|
||||
depsToGet = depsToGet.filter((f) => !isRelativePath(f.raw))
|
||||
if (depsToGet.length === 0) {
|
||||
return []
|
||||
@@ -132,7 +135,6 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
|
||||
depsToGet.map((x) => x.raw)
|
||||
)
|
||||
// Make it so it won't get re-downloaded
|
||||
depsToGet.forEach((dep) => moduleMap.set(dep.raw, { state: 'loading' }))
|
||||
|
||||
// Grab the module trees which gives us a list of files to download
|
||||
const trees = await Promise.all(
|
||||
|
||||
@@ -777,7 +777,11 @@
|
||||
|
||||
const addLocalFile = async (code: string, _path: string) => {
|
||||
let p = new URL(_path, uri).href
|
||||
// if (_path?.startsWith('/')) {
|
||||
// p = 'file://' + p
|
||||
// }
|
||||
let nuri = mUri.parse(p)
|
||||
console.log('adding local file', _path, nuri.toString())
|
||||
if (editor) {
|
||||
let localModel = meditor.getModel(nuri)
|
||||
if (localModel) {
|
||||
|
||||
Reference in New Issue
Block a user