Skip to content

Commit b550c4c

Browse files
committed
updates node template to ignore node_modules in .gitignore
Signed-off-by: KapilSareen <[email protected]>
1 parent 3239d06 commit b550c4c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/functions/client.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ func (c *Client) Init(cfg Function) (Function, error) {
588588
f := NewFunctionWith(cfg)
589589

590590
// Create a .func diretory which is also added to a .gitignore
591-
if err = ensureRunDataDir(f.Root); err != nil {
591+
if err = ensureRunDataDir(f.Root, f.Runtime); err != nil {
592592
return f, err
593593
}
594594

@@ -1097,7 +1097,7 @@ func (c *Client) Push(ctx context.Context, f Function) (Function, bool, error) {
10971097

10981098
// ensureRunDataDir creates a .func directory at the given path, and
10991099
// registers it as ignored in a .gitignore file.
1100-
func ensureRunDataDir(root string) error {
1100+
func ensureRunDataDir(root string, runtime string) error {
11011101
// Ensure the runtime directory exists
11021102
if err := os.MkdirAll(filepath.Join(root, RunDataDir), os.ModePerm); err != nil {
11031103
return err
@@ -1146,6 +1146,11 @@ func ensureRunDataDir(root string) error {
11461146
`); err != nil {
11471147
return err
11481148
}
1149+
if runtime == "node" {
1150+
if _, err = rwFile.WriteString(`node_modules`); err != nil {
1151+
return err
1152+
}
1153+
}
11491154

11501155
// Flush to disk immediately since this may affect subsequent calculations
11511156
// of the build stamp

pkg/functions/function.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func (f Function) Write() (err error) {
434434
}
435435

436436
// Write local settings
437-
err = ensureRunDataDir(f.Root)
437+
err = ensureRunDataDir(f.Root, f.Runtime)
438438
if err != nil {
439439
return
440440
}
@@ -484,7 +484,7 @@ func (f Function) Stamp(oo ...stampOption) (err error) {
484484
for _, o := range oo {
485485
o(options)
486486
}
487-
if err = ensureRunDataDir(f.Root); err != nil {
487+
if err = ensureRunDataDir(f.Root, f.Runtime); err != nil {
488488
return
489489
}
490490

@@ -710,7 +710,7 @@ func (f Function) BuildStamp() string {
710710

711711
// localSettings returns the local settings set for the function
712712
func (f Function) newLocal() (localConfig Local, err error) {
713-
err = ensureRunDataDir(f.Root)
713+
err = ensureRunDataDir(f.Root, f.Runtime)
714714
if err != nil {
715715
return
716716
}

0 commit comments

Comments
 (0)