-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Calling serverless deploy
with a --package
flag argument starting with ./
does not work
#6525
Labels
Comments
stephaneseng
added a commit
to stephaneseng/serverless
that referenced
this issue
Aug 11, 2019
…copySync() on the directories instead of calling it on the files to copy individually. Closes serverless#6525.
stephaneseng
added a commit
to stephaneseng/serverless
that referenced
this issue
Aug 11, 2019
…copySync() on the directories instead of calling it on the files to copy individually. Closes serverless#6525.
stephaneseng
added a commit
to stephaneseng/serverless
that referenced
this issue
Aug 11, 2019
…tra::copySync() on the directories instead of calling it on the files to copy individually. The main motivation behind these changes is to rely on https://github.com/jprichardson/node-fs-extra/blob/8.1.0/docs/copy-sync.md as much as possible in order to avoid having to do the `fullFilePath.replace(srcDir, '')` operation because this operation can be error-prone. Doing so fixes the following issues because the user-submitted file paths are now correctly interpreted by fs-extra, closing both serverless#6525 and serverless#5172.
stephaneseng
added a commit
to stephaneseng/serverless
that referenced
this issue
Aug 12, 2019
…tra::copySync() on the directories instead of calling it on the files to copy individually. The main motivation behind these changes is to rely on https://github.com/jprichardson/node-fs-extra/blob/8.1.0/docs/copy-sync.md as much as possible in order to avoid having to do the `fullFilePath.replace(srcDir, '')` operation because this operation can be error-prone. Doing so fixes the following issues because the user-submitted file paths are now correctly interpreted by fs-extra, closing both serverless#6525 and serverless#5172.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a Bug Report
Description
Calling
serverless deploy
with a--package
flag argument starting with./
does not work.Here are the steps to reproduce this issue:
However,
serverless deploy --package my-artifacts
works fine.Cause
An unexpected behavior occurs when serverless tries to copy the already packaged artifacts from
./my-artificats
in this case to the.serverless
temporary folder, before the deploy.This copy is triggered by the following calls:
before:deploy:deploy
hook, theaws:common:moveArtifactsToTemp
is spawned: https://github.com/serverless/serverless/blob/v1.49.0/lib/plugins/aws/deploy/index.js#L83moveArtifactsToTemp()
: https://github.com/serverless/serverless/blob/v1.49.0/lib/plugins/aws/common/index.js#L57copyDirContentsSync()
: https://github.com/serverless/serverless/blob/v1.49.0/lib/plugins/aws/common/lib/artifacts.js#L47copyDirContentsSync.js
: https://github.com/serverless/serverless/blob/v1.49.0/lib/utils/fs/copyDirContentsSync.jsWith
--package ./my-artifacts
, this copy result in the following file structure:This differs with how the resulting file structure looks with
--package my-artifacts
:This is because, when
--package ./my-artifacts
is called, when attempting to copy theserverless-state.json
file,fse.copySync(fullFilePath, path.join(destDir, relativeFilePath))
is invoked in the following context:fullFilePath = my-artifacts/serverless-state.json
destDir = /tmp/my-project/.serverless
relativeFilePath = my-artifacts/serverless-state.json
srcDir = ./my-artifacts
Here, the intent was to have
relativeFilePath = serverless-state.json
but serverless could not removesrcDir = ./my-artifacts
fromfullFilePath = my-artifacts/serverless-state.json
.Resolution proposal
This issue can be solved by calling https://github.com/jprichardson/node-fs-extra/blob/8.1.0/docs/copy-sync.md directly on the directories to copy from and to instead of calling it on the files to copy individually.
Similar or dependent issues
Issue with the same root cause:
Issues related to the
serverless-state.json
file path but I am unsure that these are due to the same root cause:Additional data
The text was updated successfully, but these errors were encountered: