MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/buildpacks / SkipSyntaxCheck

Function SkipSyntaxCheck

pkg/nodejs/nodejs.go:416–432  ·  view source on GitHub ↗

SkipSyntaxCheck returns true if we should skip checking the user's function file for syntax errors if it is impacted by https://github.com/GoogleCloudPlatform/functions-framework-nodejs/issues/407.

(ctx *gcp.Context, file string, pjs *PackageJSON)

Source from the content-addressed store, hash-verified

414}
415
416// SkipSyntaxCheck returns true if we should skip checking the user's function file for syntax errors
417// if it is impacted by https://github.com/GoogleCloudPlatform/functions-framework-nodejs/issues/407.
418func SkipSyntaxCheck(ctx *gcp.Context, file string, pjs *PackageJSON) (bool, error) {
419 nodeVer, err := nodeVersion(ctx)
420 if err != nil {
421 return false, err
422 }
423 version, err := semver.NewVersion(nodeVer)
424 if err != nil {
425 return false, gcp.InternalErrorf("failed to detect valid Node.js version %s: %v", version, err)
426 }
427 if version.Major() != 16 {
428 return false, nil
429 }
430 if strings.HasSuffix(file, ".mjs") {
431 return true, nil
432 }
433 return (pjs != nil && pjs.Type == "module"), nil
434}
435

Callers 2

BuildFnFunction · 0.92
TestSkipSyntaxCheckFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSkipSyntaxCheckFunction · 0.68