Browse Source

updated magefile to build emoji list into emoji.go and provide constant

pull/3/head
David Haukeness 5 years ago
parent
commit
e50f76ee46
No known key found for this signature in database
GPG Key ID: A7F1091956853EF9
  1. 18
      mage.go

18
mage.go

@ -8,7 +8,7 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"strings"
"github.com/magefile/mage/sh" "github.com/magefile/mage/sh"
"github.com/magefile/mage/mg" "github.com/magefile/mage/mg"
) )
@ -52,7 +52,8 @@ func createEmojiSlice() ([]string, error) {
var emojiSlice []string var emojiSlice []string
for _, emj := range emojis { for _, emj := range emojis {
if len(emj.Shortcode) == 0 { if len(emj.Shortcode) == 0 || strings.Contains(emj.Shortcode, "_tone") {
// dont add them
continue continue
} }
emojiSlice = append(emojiSlice, emj.Shortcode) emojiSlice = append(emojiSlice, emj.Shortcode)
@ -61,27 +62,24 @@ func createEmojiSlice() ([]string, error) {
} }
// Build kbtui with emoji lookup support // Build kbtui with emoji lookup support
func BuildEmoji() { func BuildEmoji() error {
emojis, err := createEmojiSlice() emojis, err := createEmojiSlice()
if err != nil { if err != nil {
fmt.Println(err.Error()) return err
return
} }
f, err := os.Create(emojiFileName) f, err := os.Create(emojiFileName)
if err != nil { if err != nil {
fmt.Println(err.Error()) return err
return
} }
defer f.Close() defer f.Close()
fileContent := fmt.Sprintf("package main\n\nvar emojiSlice = %#v", emojis) fileContent := fmt.Sprintf("package main\n\nvar emojiSlice = %#v", emojis)
_, err = f.WriteString(fileContent) _, err = f.WriteString(fileContent)
if err != nil { if err != nil {
fmt.Println(err.Error()) return err
return
} }
f.Sync() f.Sync()
//sh.Run("go", "build", "-tags", "allcommands,showreeactionscmd,emoji") return nil
} }
// Build kbtui with just the basic commands. // Build kbtui with just the basic commands.

Loading…
Cancel
Save