Skip to content

fix: use empty string path when function source is not specified #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2019

Conversation

hdp617
Copy link
Contributor

@hdp617 hdp617 commented Sep 13, 2019

I removed '/' from CODE_LOCATION that set the default function directory to root in commit #77. This causes this error in 1.3.0,

npx @google-cloud/functions-framework --target=helloWorld
The "path" argument must be of type string. Received type undefined

When --source flag and FUNCTION_SOURCE env var are not specified, one of the 'path' arguments in resolve() is undefined. This causes the error above.

I've added empty string as an argument in the case above.

fixes issue #89

… var are not specified

I removed '/' from CODE_LOCATION that set the default function directory to root in commit #77. This causes this error in 1.3.0,
```
npx @google-cloud/functions-framework --target=helloWorld
The "path" argument must be of type string. Received type undefined
```

When --source flag and FUNCTION_SOURCE env var are not specified, one of the 'path' arguments in resolve() is undefined. This causes the error above.

I've added empty string as an argument in the case above. This should fix the bug.
@hdp617 hdp617 requested a review from lukasberger September 13, 2019 14:56
@hdp617 hdp617 changed the title fix: use empty string path when --source flag and FUNCTION_SOURCE env var are not specified fix: use empty string path when function source is not specified Sep 13, 2019
src/index.ts Outdated
@@ -63,7 +63,7 @@ const argv = minimist(process.argv, {

const CODE_LOCATION = resolve(
process.cwd(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't process.cwd redundant here? According to the docs [1] the cwd is prepended to any relative path.

https://nodejs.org/docs/latest/api/path.html#path_path_resolve_paths

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is redundant. I thought the docs meant cwd would be used as a path instead of cwd being prepended.

@hdp617 hdp617 merged commit 2800649 into master Sep 13, 2019
@hdp617 hdp617 deleted the fix-path branch September 13, 2019 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants