-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild.go
More file actions
32 lines (26 loc) · 825 Bytes
/
build.go
File metadata and controls
32 lines (26 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package yaakcli
import (
"path/filepath"
"github.com/evanw/esbuild/pkg/api"
"github.com/pterm/pterm"
)
func ESLintBuildOptions(pluginDir string) api.BuildOptions {
srcPath := filepath.Join(pluginDir, "src", "index.ts")
outPath := filepath.Join(pluginDir, "build", "index.js")
return api.BuildOptions{
EntryPoints: []string{srcPath},
Outfile: outPath,
Platform: api.PlatformNode,
Bundle: true, // Inline dependencies
Write: true, // Write to disk
Format: api.FormatCommonJS,
LogLevel: api.LogLevelInfo,
}
}
func BuildPlugin(dir string) {
if !fileExists(filepath.Join(dir, "package.json")) {
ExitError("./package.json does not exist. Ensure that you are in a plugin directory.")
}
pterm.Info.Printf("Building plugin %s...\n", dir)
api.Build(ESLintBuildOptions(dir))
}