Skip to content

Commit

Permalink
fix: write npmrc file if NpmRegistry is set fixes #737 (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
edeustace authored Nov 5, 2023
1 parent 94b11d9 commit 8b0300b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (task *BuildTask) Build() (esm *ESMBuild, err error) {
return
}

if cfg.NpmToken != "" || (cfg.NpmUser != "" && cfg.NpmPassword != "") {
if cfg.NpmRegistry != "" || cfg.NpmToken != "" || (cfg.NpmUser != "" && cfg.NpmPassword != "") {
rcFilePath := path.Join(task.wd, ".npmrc")
if !fileExists(rcFilePath) {
var output bytes.Buffer
Expand Down Expand Up @@ -102,7 +102,6 @@ func (task *BuildTask) Build() (esm *ESMBuild, err error) {
output.WriteString(fmt.Sprintf("%s:username=${ESM_NPM_USER}\n", tokenReg))
output.WriteString(fmt.Sprintf("%s:_password=${ESM_NPM_PASSWORD}\n", tokenReg))
}

err = os.WriteFile(rcFilePath, output.Bytes(), 0644)
if err != nil {
log.Errorf("Failed to create .npmrc file: %v", err)
Expand Down

0 comments on commit 8b0300b

Please sign in to comment.