Skip to content

Commit

Permalink
embed an npmrc
Browse files Browse the repository at this point in the history
  • Loading branch information
jimisaacs committed Sep 8, 2021
1 parent 51451c6 commit 8fd702e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

//go:embed embed
//go:embed README.md
//go:embed npmrc
var fs embed.FS

func main() {
Expand Down
1 change: 1 addition & 0 deletions npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry = https://registry.npmjs.org/
11 changes: 11 additions & 0 deletions server/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,17 @@ func installNodejs(dir string, version string) (err error) {
if len(output) > 0 {
err = errors.New(string(output))
}
} else {
npmrc, err := embedFS.ReadFile("npmrc")
if err == nil {
err = os.MkdirAll(fmt.Sprintf("%s/etc", dir), os.ModePerm)
if err == nil || os.IsExist(err) {
err = os.WriteFile(fmt.Sprintf("%s/etc/npmrc", dir), npmrc, os.ModePerm)
}
if os.IsExist(err) {
err = nil
}
}
}
return
}
Expand Down

0 comments on commit 8fd702e

Please sign in to comment.