Skip to content
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

Return permissions error directly #130

Merged
merged 1 commit into from
Nov 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions cli-sdk/index.js
Expand Up @@ -39,11 +39,7 @@ const exceptionWrapper = function tryCatchWrapper(funcToWrap) {
await funcToWrap(options);
return 0;
} catch (err) {
if (err.code === 'EACCES') {
log.error(`Permission denied writing to path: ${err.path}`);
} else {
log.error(err.message);
}
log.error(err.message);
return 1;
}
};
Expand Down
2 changes: 1 addition & 1 deletion test/CLISpec.yml
Expand Up @@ -123,7 +123,7 @@
steps:
- in: bn init -p /home/dockeruser/test/securedir
out: |-
bn: Permission denied writing to path: /home/dockeruser/test/securedir*
bn: EACCES: permission denied, unlink '/home/dockeruser/test/securedir/function.js'
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the first privileged operation we do unlink?

Copy link
Contributor Author

@rylandg rylandg Nov 11, 2017

Choose a reason for hiding this comment

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

To copy our template function.js file to the users function directory we use the copy method in fs-extra. Looking at the source code here I can see that they use fs.unlink to ensure that there is no other file handle in the location where the user wants the file copied.

Funny enough here's an issue currently in progress to replace unlink with rename

exit: 1

- test: Superfluous output(bad-path)
Expand Down