@@ -147,7 +147,10 @@ func NewDeployCommand() *cli.Command {
147147 }
148148
149149 // Try to auto-detect from git remote
150- dir , _ := os .Getwd ()
150+ dir , err := os .Getwd ()
151+ if err != nil {
152+ return fmt .Errorf ("couldn't determine your current directory — please try again from a valid working directory" )
153+ }
151154 repoFullName := git .GetRemoteFullName (dir )
152155 if repoFullName != "" {
153156 for _ , p := range activeProjects {
@@ -160,10 +163,10 @@ func NewDeployCommand() *cli.Command {
160163 }
161164 if src .VCSFullName == repoFullName {
162165 pterm .Info .Printf ("Detected project %s from git remote (%s)\n " , p .DisplayName , repoFullName )
163- useDetected , _ := pterm .DefaultInteractiveConfirm .
166+ confirm := pterm .DefaultInteractiveConfirm .
164167 WithDefaultText (fmt .Sprintf ("Deploy %s?" , p .DisplayName )).
165- WithDefaultValue (true ).
166- Show ()
168+ WithDefaultValue (true )
169+ useDetected , _ := confirm . Show () //nolint:errcheck
167170 if useDetected {
168171 projectID = p .ID
169172 }
@@ -281,23 +284,23 @@ func UploadDir(client *api.APIClient, projectID, displayName, dir string) error
281284 defer os .Remove (zipFile .Name ()) //nolint:errcheck
282285 defer zipFile .Close () //nolint:errcheck
283286
284- spinner , _ := pterm .DefaultSpinner .Start ("Packaging files..." )
287+ spinner , _ := pterm .DefaultSpinner .Start ("Packaging files..." ) //nolint:errcheck
285288
286- if err : = createZip (zipFile , absDir ); err != nil {
289+ if err = createZip (zipFile , absDir ); err != nil {
287290 spinner .Fail ("Packaging failed" )
288291 return err
289292 }
290293
291- stat , _ := zipFile .Stat ()
292- if stat ! = nil && stat .Size () > maxZipSize {
294+ stat , statErr := zipFile .Stat ()
295+ if statErr = = nil && stat .Size () > maxZipSize {
293296 spinner .Fail ("Package too large" )
294297 return fmt .Errorf ("deployment package is %d MB (max %d MB)\n \n Tip: check that node_modules, .git, and build artifacts are excluded" ,
295298 stat .Size ()/ (1024 * 1024 ), maxZipSize / (1024 * 1024 ))
296299 }
297300
298301 spinner .UpdateText ("Uploading..." )
299302
300- if err : = zipFile .Close (); err != nil { //nolint:govet
303+ if err = zipFile .Close (); err != nil {
301304 return fmt .Errorf ("could not flush deployment package: %w" , err )
302305 }
303306
@@ -335,15 +338,15 @@ func deployUpload(c *cli.Context, client *api.APIClient, project *api.Project) e
335338 defer os .Remove (zipFile .Name ()) //nolint:errcheck
336339 defer zipFile .Close () //nolint:errcheck
337340
338- spinner , _ := pterm .DefaultSpinner .Start ("Packaging files..." )
341+ spinner , _ := pterm .DefaultSpinner .Start ("Packaging files..." ) //nolint:errcheck
339342
340- if err : = createZip (zipFile , absDir ); err != nil {
343+ if err = createZip (zipFile , absDir ); err != nil {
341344 spinner .Fail ("Packaging failed" )
342345 return err
343346 }
344347
345- stat , _ := zipFile .Stat ()
346- if stat ! = nil && stat .Size () > maxZipSize {
348+ stat , statErr := zipFile .Stat ()
349+ if statErr = = nil && stat .Size () > maxZipSize {
347350 spinner .Fail ("Package too large" )
348351 return fmt .Errorf ("deployment package is %d MB (max %d MB)\n \n Tip: check that node_modules, .git, and build artifacts are excluded" ,
349352 stat .Size ()/ (1024 * 1024 ), maxZipSize / (1024 * 1024 ))
@@ -352,7 +355,7 @@ func deployUpload(c *cli.Context, client *api.APIClient, project *api.Project) e
352355 spinner .UpdateText ("Uploading..." )
353356
354357 // Close before uploading so the file is flushed
355- if err : = zipFile .Close (); err != nil { //nolint:govet
358+ if err = zipFile .Close (); err != nil {
356359 return fmt .Errorf ("could not flush deployment package: %w" , err )
357360 }
358361
@@ -523,8 +526,15 @@ func createZip(w io.Writer, srcDir string) error {
523526 // Check ignore patterns against basename and full relative path
524527 baseName := filepath .Base (relPath )
525528 for _ , pattern := range ignorePatterns {
526- matchedBase , _ := filepath .Match (pattern , baseName )
527- matchedRel , _ := filepath .Match (pattern , filepath .ToSlash (relPath ))
529+ var matchedBase , matchedRel bool
530+ matchedBase , err = filepath .Match (pattern , baseName )
531+ if err != nil {
532+ return fmt .Errorf ("invalid ignore pattern %q: %w" , pattern , err )
533+ }
534+ matchedRel , err = filepath .Match (pattern , filepath .ToSlash (relPath ))
535+ if err != nil {
536+ return fmt .Errorf ("invalid ignore pattern %q: %w" , pattern , err )
537+ }
528538 if matchedBase || matchedRel {
529539 if info .IsDir () {
530540 return filepath .SkipDir
0 commit comments