diff options
| author | ewy <ewy0@protonmail.com> | 2026-05-02 18:28:40 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-05-02 18:28:40 +0200 |
| commit | e8b9ca135642c76000bc0ec2e78674c602a748dd (patch) | |
| tree | 4e502ce767a4a4f70e40d6e72a3817bc139f1300 /runner/js/runner.go | |
| parent | 35e6ac334f6a62cf63b743182cd5355f6baf4406 (diff) | |
add .js and .ts support
also: remove unused/duplicate method runner.Hydrate
Diffstat (limited to 'runner/js/runner.go')
| -rw-r--r-- | runner/js/runner.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/runner/js/runner.go b/runner/js/runner.go new file mode 100644 index 0000000..8b5f4f1 --- /dev/null +++ b/runner/js/runner.go @@ -0,0 +1,28 @@ +package js + +import ( + "github.com/ewy1/pik/identity" + "github.com/ewy1/pik/model" + "github.com/ewy1/pik/runner" + "io/fs" + "path/filepath" + "slices" +) + +func (n *js) Wants(fs fs.FS, file string, entry fs.DirEntry) (bool, error) { + ext := filepath.Ext(entry.Name()) + return slices.Contains(extensions, ext), nil +} + +func (n *js) CreateTarget(fs fs.FS, source string, file string, entry fs.DirEntry) (model.Target, error) { + ext := filepath.Ext(entry.Name()) + typed := slices.Contains(tsExtensions, ext) + return &Script{ + BaseTarget: runner.BaseTarget{ + Identity: identity.New(entry.Name()), + MyTags: model.TagsFromFilename(entry.Name()), + MySub: runner.SubFromFile(file), + }, + Typed: typed, + }, nil +} |
