fix(build): Disallow --build-dir to resolve to cwd#1403
fix(build): Disallow --build-dir to resolve to cwd#1403sanathkr merged 4 commits intoaws:developfrom
Conversation
samcli/commands/build/command.py
Outdated
| default=DEFAULT_BUILD_DIR, | ||
| type=click.Path(file_okay=False, dir_okay=True, writable=True), # Must be a directory | ||
| help="Path to a folder where the built artifacts will be stored") | ||
| help="Path to a folder where the built artifacts will be stored. If a clean build, this directory will be first removed.") |
There was a problem hiding this comment.
we always do a clean build. So the 'if' shouldn't be necessary
There was a problem hiding this comment.
The wording was future looking. I can remove. Do we even mention clean build is all we support anywhere today?
| build_path = pathlib.Path(build_dir) | ||
|
|
||
| if os.path.abspath(str(build_path)) == os.path.abspath(str(pathlib.Path.cwd())): | ||
| exception_message = "'build-dir' should not be the current workding directoy as the directory " \ |
There was a problem hiding this comment.
can we instead skip the "clean" if build-dir == cwd? It could give to a more intuitive experience
There was a problem hiding this comment.
Not sure I completely understand. My current understanding of the question is:
"Instead of always doing a "clean" build, we would not do a clean build if build-dir == cwd"?
If that is a fair rewording, then I don't think we should go down this route. Having a conditional do clean or not base upon a parameter that does not relate to a 'clean build' is not intuitive at all. This will make supporting clean builds more difficult in the future.
Issue #, if available:
#1157
Description of changes:
Checklist:
make prpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.