You've already forked go-semantic-release
Integrations are simple helpers to make integration with existing tools easier.
At basic npm support, the integration will set the version before release to the `package.json`
```yml
integrations:
npm:
enabled: true
```
29 lines
579 B
Go
29 lines
579 B
Go
package integrations
|
|
|
|
import (
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/tidwall/sjson"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func (i *Integrations) updateNPM() error {
|
|
|
|
npmConfig := i.config.NPM
|
|
if npmConfig.Path == "" {
|
|
npmConfig.Path = "./package.json"
|
|
}
|
|
|
|
log.Debugf("Set version %s to %s", i.version.Next.Version, npmConfig.Path)
|
|
data, err := ioutil.ReadFile(npmConfig.Path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
newData, err := sjson.Set(string(data), "version", i.version.Next.Version)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return ioutil.WriteFile(npmConfig.Path, []byte(newData), 0777)
|
|
}
|