@@ -42,7 +42,7 @@ const (
4242 lfsVersionString = "version https://git-lfs.github.com/spec/v1"
4343)
4444
45- var ignoreInstallDirs = []string {"node_modules/" , "bower_components/" }
45+ var installDirs = []string {"node_modules/" , "bower_components/" }
4646
4747type uploadType int
4848type pointerData struct {
@@ -74,6 +74,7 @@ type DeployOptions struct {
7474 SiteID string
7575 Dir string
7676 FunctionsDir string
77+ BuildDir string
7778 LargeMediaEnabled bool
7879
7980 IsDraft bool
@@ -190,8 +191,10 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
190191 largeMediaEnabled = deploy .SiteCapabilities .LargeMediaEnabled
191192 }
192193
194+ ignoreInstallDirs := options .Dir == options .BuildDir
195+
193196 context .GetLogger (ctx ).Infof ("Getting files info with large media flag: %v" , largeMediaEnabled )
194- files , err := walk (options .Dir , options .Observer , largeMediaEnabled )
197+ files , err := walk (options .Dir , options .Observer , largeMediaEnabled , ignoreInstallDirs )
195198 if err != nil {
196199 if options .Observer != nil {
197200 options .Observer .OnFailedWalk ()
@@ -500,16 +503,10 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
500503 }
501504}
502505
503- var getwd = os .Getwd
504-
505- func walk (dir string , observer DeployObserver , useLargeMedia bool ) (* deployFiles , error ) {
506+ func walk (dir string , observer DeployObserver , useLargeMedia , ignoreInstallDirs bool ) (* deployFiles , error ) {
506507 files := newDeployFiles ()
507- cwd , err := getwd ()
508- if err != nil {
509- return nil , err
510- }
511508
512- err = filepath .Walk (dir , func (path string , info os.FileInfo , err error ) error {
509+ err : = filepath .Walk (dir , func (path string , info os.FileInfo , err error ) error {
513510 if err != nil {
514511 return err
515512 }
@@ -521,7 +518,7 @@ func walk(dir string, observer DeployObserver, useLargeMedia bool) (*deployFiles
521518 }
522519 rel := forceSlashSeparators (osRel )
523520
524- if ignoreFile (rel , dir == cwd ) {
521+ if ignoreFile (rel , ignoreInstallDirs ) {
525522 return nil
526523 }
527524
@@ -745,14 +742,14 @@ func goFile(filePath string, i os.FileInfo, observer DeployObserver) bool {
745742 return true
746743}
747744
748- func ignoreFile (rel string , deployFromBuildDir bool ) bool {
745+ func ignoreFile (rel string , ignoreInstallDirs bool ) bool {
749746 if strings .HasPrefix (rel , "." ) || strings .Contains (rel , "/." ) || strings .HasPrefix (rel , "__MACOS" ) {
750747 return ! strings .HasPrefix (rel , ".well-known/" )
751748 }
752- if ! deployFromBuildDir {
749+ if ! ignoreInstallDirs {
753750 return false
754751 }
755- for _ , ignorePath := range ignoreInstallDirs {
752+ for _ , ignorePath := range installDirs {
756753 if strings .HasPrefix (rel , ignorePath ) {
757754 return true
758755 }
0 commit comments