Skip to content

Commit

Permalink
assign nil value to strictSSL when only using flags
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng92 committed Aug 15, 2024
1 parent 91b76a4 commit 6a8bf35
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/cmd/run/cypress.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ func runCypress(cmd *cobra.Command, isCLIDriven bool) (int, error) {
if err := p.ApplyFlags(gFlags.selectedSuite); err != nil {
return 1, err
}

// If npm.strictSSL is not explicitly set via the flag and not configured via the config file,
// `StrictSSL` should remain unset, which means it should be nil.
if !cmd.Flags().Changed("npm.strictSSL") && gFlags.cfgFilePath == "" {
p.SetNpmStrictSSL(nil)
}

p.SetDefaults()
if !gFlags.noAutoTagging {
p.AppendTags(ci.GetTags())
Expand Down
6 changes: 6 additions & 0 deletions internal/cmd/run/playwright.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func runPlaywright(cmd *cobra.Command, isCLIDriven bool) (int, error) {

p.CLIFlags = flags.CaptureCommandLineFlags(cmd.Flags())

// If npm.strictSSL is not explicitly set via the flag and not configured via the config file,
// `StrictSSL` should remain unset, which means it should be nil.
if !cmd.Flags().Changed("npm.strictSSL") && gFlags.cfgFilePath == "" {
p.Npm.StrictSSL = nil
}

if err := applyPlaywrightFlags(&p); err != nil {
return 1, err
}
Expand Down
6 changes: 6 additions & 0 deletions internal/cmd/run/testcafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ func runTestcafe(cmd *cobra.Command, tcFlags testcafeFlags, isCLIDriven bool) (i

p.CLIFlags = flags.CaptureCommandLineFlags(cmd.Flags())

// If npm.strictSSL is not explicitly set via the flag and not configured via the config file,
// `StrictSSL` should remain unset, which means it should be nil.
if !cmd.Flags().Changed("npm.strictSSL") && gFlags.cfgFilePath == "" {
p.Npm.StrictSSL = nil
}

if err := applyTestcafeFlags(&p, tcFlags); err != nil {
return 1, err
}
Expand Down
1 change: 1 addition & 0 deletions internal/cypress/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Project interface {
GetReporters() config.Reporters
GetNotifications() config.Notifications
GetNpm() config.Npm
SetNpmStrictSSL(strictSSL *bool)
SetCLIFlags(map[string]interface{})
GetSuites() []suite.Suite
GetKind() string
Expand Down
4 changes: 4 additions & 0 deletions internal/cypress/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ func (p *Project) GetNpm() config.Npm {
return p.Npm
}

func (p *Project) SetNpmStrictSSL(strictSSL *bool) {
p.Npm.StrictSSL = strictSSL
}

// SetCLIFlags sets cli flags
func (p *Project) SetCLIFlags(flags map[string]interface{}) {
p.CLIFlags = flags
Expand Down

0 comments on commit 6a8bf35

Please sign in to comment.