diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index d74ff0fb..6e783c67 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -55,10 +55,7 @@ jobs: strategy: fail-fast: false matrix: - # windows-latest is intentionally excluded: the WASM Windows-host path is - # experimental and not yet passing (driver discovery under GOOS=js — see - # https://github.com/columnar-tech/dbc/issues/396). Re-add when fixed. - os: [ 'ubuntu-latest', 'macos-latest' ] + os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: diff --git a/config/config.go b/config/config.go index 53206fd8..a7b725fb 100644 --- a/config/config.go +++ b/config/config.go @@ -148,28 +148,6 @@ func EnsureLocation(cfg Config) (string, error) { return loc, nil } -func loadDir(dir string) (map[string]DriverInfo, error) { - if _, err := os.Stat(dir); err != nil { - return nil, err - } - - ret := make(map[string]DriverInfo) - - fsys := os.DirFS(dir) - matches, _ := fs.Glob(fsys, "*.toml") - for _, m := range matches { - p := filepath.Join(dir, m) - di, err := loadDriverFromManifest(filepath.Dir(p), filepath.Base(p)) - if err != nil { - continue - } - - di.FilePath = filepath.Dir(p) - ret[di.ID] = di - } - return ret, nil -} - func loadConfig(lvl ConfigLevel) Config { cfg := Config{Level: lvl, Location: lvl.ConfigLocation()} if cfg.Location == "" { diff --git a/config/loaddir_js.go b/config/loaddir_js.go new file mode 100644 index 00000000..06b69c82 --- /dev/null +++ b/config/loaddir_js.go @@ -0,0 +1,54 @@ +// Copyright 2026 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build js + +package config + +import ( + "os" + "path/filepath" + "strings" +) + +// loadDir lists installed drivers from a directory. Under GOOS=js, os.ReadDir +// and os.DirFS fail on Windows hosts because Go's js/wasm syscall layer rejects +// the O_DIRECTORY flag (Node.js does not expose it on Windows). We work around +// this by using os.Open (which omits O_DIRECTORY) followed by File.ReadDir. +func loadDir(dir string) (map[string]DriverInfo, error) { + f, err := os.Open(dir) + if err != nil { + return nil, err + } + entries, err := f.ReadDir(-1) + f.Close() + if err != nil { + return nil, err + } + + ret := make(map[string]DriverInfo) + for _, e := range entries { + if e.IsDir() || !strings.HasSuffix(e.Name(), ".toml") { + continue + } + p := filepath.Join(dir, e.Name()) + di, err := loadDriverFromManifest(filepath.Dir(p), filepath.Base(p)) + if err != nil { + continue + } + di.FilePath = filepath.Dir(p) + ret[di.ID] = di + } + return ret, nil +} diff --git a/config/loaddir_other.go b/config/loaddir_other.go new file mode 100644 index 00000000..e0f809a0 --- /dev/null +++ b/config/loaddir_other.go @@ -0,0 +1,45 @@ +// Copyright 2026 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !js + +package config + +import ( + "io/fs" + "os" + "path/filepath" +) + +func loadDir(dir string) (map[string]DriverInfo, error) { + if _, err := os.Stat(dir); err != nil { + return nil, err + } + + ret := make(map[string]DriverInfo) + + fsys := os.DirFS(dir) + matches, _ := fs.Glob(fsys, "*.toml") + for _, m := range matches { + p := filepath.Join(dir, m) + di, err := loadDriverFromManifest(filepath.Dir(p), filepath.Base(p)) + if err != nil { + continue + } + + di.FilePath = filepath.Dir(p) + ret[di.ID] = di + } + return ret, nil +}