-
Notifications
You must be signed in to change notification settings - Fork 10
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
lib: make safeRequire()
return tuple
#226
Conversation
lib/record-serialization.js
Outdated
@@ -12,7 +12,7 @@ module.exports = jsrs; | |||
// one of our priorities to optimize it. | |||
const USE_NATIVE_SERIALIZER = false; | |||
|
|||
const jstpNative = | |||
const [error, jstpNative] = | |||
safeRequire('../build/Release/jstp') || |
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.
This won't work.
test/node/common-safe-require.js
Outdated
|
||
test.equal(common.safeRequire(nonExistingModule), null, | ||
test.equal(common.safeRequire(nonExistingModule)[1], null, |
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.
[0]
disregard it
test/node/common-safe-require.js
Outdated
@@ -7,7 +7,7 @@ const common = require('../../lib/common'); | |||
const existingModule = 'fs'; | |||
const nonExistingModule = '__non_existing_module__'; | |||
|
|||
test.ok(common.safeRequire(existingModule), 'must require existing module'); | |||
test.ok(common.safeRequire(existingModule), 'must require existing module'[1]); |
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.
I believe you didn't mean to compare an array with 'm' ;)
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.
That's error message =). But yeah it was funny.
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.
ah, it's not a comparison, but a test message
test/node/common-safe-require.js
Outdated
@@ -7,7 +7,7 @@ const common = require('../../lib/common'); | |||
const existingModule = 'fs'; | |||
const nonExistingModule = '__non_existing_module__'; | |||
|
|||
test.ok(common.safeRequire(existingModule), 'must require existing module'); | |||
test.ok(common.safeRequire(existingModule), 'must require existing module'[1]); |
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.
I think [1]
should be in a different place =).
test/node/common-safe-require.js
Outdated
|
||
test.equal(common.safeRequire(nonExistingModule), null, | ||
test.equal(common.safeRequire(nonExistingModule)[1], null, |
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.
Why don't we test this with notOk
as the one above is tested with ok
?
UPD: @nechaido ping.
lib/record-serialization.js
Outdated
let [error, jstpNative] = safeRequire('../build/Release/jstp'); | ||
|
||
if (error) { | ||
[error, jstpNative] = safeRequire('../build/Debug/jstp'); |
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.
error
will be overwritten here, losing the original error.
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.
Yeah, I'd rather only show the error that occurred trying to load the release build when both failed if we opt for showing only one. Alternatively, we may show both, like we do now. I'm fine with it both ways, slightly leaning towards the former one.
Alternative PR: #216. Whichever wins the race will land on master. |
b7bfda3
to
805b708
Compare
Landed in 35c6a8c. |
Refs: metarhia/jstp#216 Closes: metarhia/jstp#188 PR-URL: metarhia/jstp#226 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Mykola Bilochub <nbelochub@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Refs: metarhia/jstp#216 Closes: metarhia/jstp#188 PR-URL: metarhia/jstp#226 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Mykola Bilochub <nbelochub@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Refs: metarhia/jstp#216 Closes: metarhia/jstp#188 PR-URL: metarhia/jstp#226 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Mykola Bilochub <nbelochub@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
As we discussed in #216 I add a PR that fixes #188 using different approach.
Refs:#216.
Closes: #188.