-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix: conditional binding (#23) #24
Conversation
…mport for things like `permissions.AuthType` as function params with a generic import that is platform-agnostic. Enhancement and fixes: codebytere#23 Adding additional test to run on a separate linux node
@codebytere it seems that xcode 12.4 changed some things and now it throws this error when attempting to build:
I've commented out that line since they're duplicate values and left an additional comment on the new behavior. node-mac-permissions/permissions.mm Lines 273 to 274 in 321a1f8
|
@mmaietta if you rebase it should be good now |
@@ -34,16 +51,7 @@ function askForFoldersAccess(folder) { | |||
} | |||
|
|||
module.exports = { | |||
askForCalendarAccess: permissions.askForCalendarAccess, | |||
askForContactsAccess: permissions.askForContactsAccess, | |||
...permissions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably also need to handle calls to askForFoldersAccess
and getAuthStatus
- permissions.askForFoldersAccess.call(this, folder)
@ L33 for example probably blows up, does it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should also be covered in the additional unit test that runs on Linux 🙂
node-mac-permissions/test/module.spec.js
Lines 67 to 68 in 321a1f8
expect(permissions.getAuthStatus('contacts')).to.be.undefined | |
expect(permissions.askForFoldersAccess('desktop')).to.be.undefined |
The type/folder is validated, and the call is still to permissions.askForFoldersAccess: () => undefined
from the original stub, so it behaves as expected with the test's assert. I originally had nonMacResponse = (...args) => undefined
but then ...args
was just flagged as unused.
These two tests also run on all nodes to enforce consistency of the arg cross-platform.
node-mac-permissions/test/module.spec.js
Lines 10 to 14 in 321a1f8
it('should throw on invalid types', () => { | |
expect(() => { | |
permissions.getAuthStatus('bad-type') | |
}).to.throw(/bad-type is not a valid type/) | |
}) |
node-mac-permissions/test/module.spec.js
Lines 40 to 44 in 321a1f8
it('should throw on invalid types', () => { | |
expect(() => { | |
permissions.askForFoldersAccess('bad-type') | |
}).to.throw(/bad-type is not a valid protected folder/) | |
}) |
The only notable difference is that the
index.d.ts
does not specify the new undefined
behavior. I felt that was acceptable as this is explicitly a mac-only module, this enhancement is mainly to allow type-safety with a standard import in local projects.
321a1f8
to
92e80cd
Compare
…mport for things like `permissions.AuthType` as function params with a generic import that is platform-agnostic. Enhancement and fixes: codebytere#23 Adding additional test to run on a separate linux node
92e80cd
to
b1d9399
Compare
# Conflicts: # README.md # index.js # package.json # test/module.spec.js
Marking as ready for review. My team and I have already been leveraging this implementation via patch-package. |
Enhancement and fixes: #23 (Module did not self-register)
#23 occurs because of Linux having no export defined due to having no sources
node-mac-permissions/binding.gyp
Lines 4 to 10 in c74d338
Adding conditional binding so that we can retain type-safety of the import for things like
permissions.AuthType
as function params with a generic import that is platform-agnostic.Adding an additional test to run on a separate Linux node for this use case
Opening as DRAFT because I'm unable to actually test this on Linux, only verified through Github actions Ubuntu node and through headless docker container (via
xvfb-run
). Going to test on windows soon. Wanted to get a head start on any feedback though to make sure I'm not already off the rails