Skip to content

Instantly share code, notes, and snippets.

@SilverCory
Created March 30, 2019 10:30
Show Gist options
  • Save SilverCory/8f02068b36e48e71983251adaf04c6ae to your computer and use it in GitHub Desktop.
Save SilverCory/8f02068b36e48e71983251adaf04c6ae to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
func main() {
inputFilePtr := flag.String("input", "./node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js", "The file to fix.")
flag.Parse()
filePath, err := filepath.Abs(*inputFilePtr)
if err != nil {
_, err := fmt.Fprintf(os.Stderr, "Unable to find the file.\n\t%v\n", err)
if err != nil {
panic(err)
}
return
}
data, err := ioutil.ReadFile(filePath)
if err != nil {
_, err := fmt.Fprintf(os.Stderr, "Unable to read the file.\n\t%v\n", err)
if err != nil {
panic(err)
}
return
}
data = bytes.Replace(data, []byte("'iOS'"), []byte("'com.apple.CoreSimulator.SimRuntime.iOS'"), 1)
data = bytes.Replace(data, []byte("'tvOS'"), []byte("'com.apple.CoreSimulator.SimRuntime.tvOS'"), 1)
if err := ioutil.WriteFile(filePath, data, os.ModePerm); err != nil {
_, err := fmt.Fprintf(os.Stderr, "Unable to write the file.\n\t%v\n", err)
if err != nil {
panic(err)
}
return
}
fmt.Println("ヽ( •_)ᕗ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment