Skip to content

Instantly share code, notes, and snippets.

@apoorvmote
Created February 24, 2021 03:12
Show Gist options
  • Save apoorvmote/a6cc98efe01bde07661ad50cc452400b to your computer and use it in GitHub Desktop.
Save apoorvmote/a6cc98efe01bde07661ad50cc452400b to your computer and use it in GitHub Desktop.
# https://taskfile.dev
version: '3'
includes:
project1:
taskfile: ./project1/Taskfile.yml
dir: ./project1
project2:
taskfile: ./project2/Taskfile.yml
dir: ./project2
project3:
taskfile: ./project3/Taskfile.yml
dir: ./project3
tasks:
default:
cmds:
- task project1:update
- task project2:update
- task project3:update
package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
)
func main() {
old := "1.83.0"
new := "1.84.0"
paths := []string{
"./project1/package.json",
"./project2/package.json",
"./project3/package.json",
}
for _, path := range paths {
input, err := ioutil.ReadFile(path)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
output := bytes.Replace(input, []byte(old), []byte(new), -1)
err = ioutil.WriteFile(path, output, 0644)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
}
# https://taskfile.dev
version: '3'
tasks:
update:
cmds:
- rm -rf node_modules/
- npm i
old := "1.83.0"
new := "1.84.0"
old1 := "0.83.0"
new1 := "0.84.0"
...
output := bytes.Replace(input, []byte(old), []byte(new), -1)
output1 := bytes.Replace(input, []byte(old1), []byte(new1), -1)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment