Sybren A. Stüvel 380d55b4f0 Cleanup: rename job_compilers/path.go to js_path.go
Rename the file by adding `js_` suffix, to indicate it's for exposing a
"path" object to JavaScript.

No functional changes.
2022-06-20 15:57:03 +02:00

27 lines
707 B
Go

package job_compilers
// SPDX-License-Identifier: GPL-3.0-or-later
import (
"git.blender.org/flamenco/pkg/crosspath"
"github.com/dop251/goja"
"github.com/rs/zerolog/log"
)
// PathModule provides file path manipulation functions by wrapping Go's `path`.
func PathModule(r *goja.Runtime, module *goja.Object) {
obj := module.Get("exports").(*goja.Object)
mustExport := func(name string, value interface{}) {
err := obj.Set(name, value)
if err != nil {
log.Panic().Err(err).Msgf("unable to register '%s' in Goja 'path' module", name)
}
}
mustExport("basename", crosspath.Base)
mustExport("dirname", crosspath.Dir)
mustExport("join", crosspath.Join)
mustExport("stem", crosspath.Stem)
}