-
Notifications
You must be signed in to change notification settings - Fork 121
Adds support for local installation of phantomjs. Fixes #31 #32
Conversation
Thanks a lot! I'll review it, test it and merge it tonight if its all good. |
@maksimr I tested you fix during lunch. It works. What do you think of this alternate implementation. I think it is easier to understand:
|
Looks good. The I tend to be a bit more hesitant to use var-declerations inside of if-statements my self, as I think it can give a false impression of a block scope. But I don't know if it is in thread with the style of this project to manually hoist variable declarations. |
I agree with your comment about var-declarations inside of if-statements. So, do want to update your PR to check the exe or you prefer that I close your PR and fix it myself? |
I thought it'd be easier for me to just update the PR. Both for review reasons and less manual labor. |
I ran |
@mikaelbr Looks good to me! Would you please squash your 3 commits before I merge this in? Thanks a lot. |
Done and done! No problem! |
@mikaelbr I have one last request for you. Would you please change your commit message to:
We need this to generate our changelog correctly. |
if (isLocal) { | ||
packageRoot = path.join(absolutePath, '\\..\\..'); | ||
return path.join(packageRoot, '\\bin\\phantomjs'); | ||
} |
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.
@sylvain-hamel can this block be replaced with just
return path.join(isLocal ? process.cwd() : absolutePath, '/node_modules/phantomjs/bin/phantomjs');
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.
- The forward slashes make it a lot easier to read
process.cwd()
: is this reliable? could external code change it before we get here?- I like to see the
npmGlobalRoot
andpackageRoot
variables though. It helps understand how we come up with those paths
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.
- hmm the slashes dont matter as
join
takes care of it for us - yup
cwd()
is reliable for a process - well in that case assign
packageRoot
to justprocess.cwd()
.
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 know, that's why I prefer
/
to\\
, just like you did - but could't another plug-in change
cwd
before we get here? - indeed
@mikaelbr would you please consider those comments when you send updated PR (for the commit message)?
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 very much agree with using
/
. - Using
process.cwd()
will force using phantomjs installed as a depencency to this runner? What if phantomjs is installed as a project dep. it self?require('phantomjs').path
can return path to a dependency outside of this module. Is this a problem at all?
I've updated to use |
cool then! , sry i didnt think about getting a phantom binary from outside the module. |
For me it comes down to the two main differences: Either run PhantomJS through node bin or use the executable directly. I don't feel I have enough knowledge about PhantomJS it self to say if running the exe directly it self is bad or not, but it seems like you'd miss out on the error handling and such from the bin file? |
I had some troubles using local installs with the latest version, as I see others have in issue #31.
This seem to be due to the pull request #29.
In CI-systems it makes sense to have local installations to not mix versions.
In my case the
cmd
variable (location
from PhantomJS) waswhich caused the
phantom
-variable to beThis is a non existing path, as the path really is without the
lib\phantom
.I'm not entirely sure that this is correct for all instances and all cases, but by removing the
lib/phantom
it worked with both global and local installs on our system - with fresh installs.It would be great if e.g. @gillius could test this as well.