You've already forked go-semantic-release
feat(integrations): add first simple npm integration
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
```
This commit is contained in:
committed by
Felix Wiedmann
parent
47a54436f5
commit
c7d6c7cc7b
28
internal/integrations/npm.go
Normal file
28
internal/integrations/npm.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user