bitovi / launchpad

NodeJS Browser Launcher
MIT License
47 stars 28 forks source link

Add path query for chromium #62

Open mattyclarkson opened 8 years ago

mattyclarkson commented 8 years ago

Assumes that the use has head installed and that it supports the -n1 argument. This will strip the first found browser from the which command.

Fixes #46

mattyclarkson commented 8 years ago

Just figuring out the build failures :cry:

mattyclarkson commented 8 years ago

Changing which google-chrome to which chromium makes the Firefox test fail. Trying to figure out what the hell is going on.

mattyclarkson commented 8 years ago

Oh, the process key defines the name of the executable (which is expected to be chrome but is actually chromium).

mattyclarkson commented 8 years ago

I've had more time to look into this and the exec function call isn't correctly returning the results of the which invocations.

var exec = require('child_process').exec;
exec('which chromium-browser chromium google-chrome google-chrome-stable || true');

If I run the following script in my node terminal I get:

> null '/usr/bin/chromium\n' 'which: no chromium-browser in (/home/matt/.npm-global-packages/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.posix_scripts)\nwhich: no google-chrome in (/home/matt/.npm-global-packages/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.posix_scripts)\nwhich: no google-chrome-stable in (/home/matt/.npm-global-packages/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.posix_scripts)\n'

If I run the same code inside the npm test I get:

null '' 'not found: chromium-browser\n'

Will carry on investigating.

mattyclarkson commented 8 years ago

The difference between npm test and grunt test results in different exec results:

npm test

[launchpad|chromium ↑·3|✚ 1] npm test

> launchpad@0.5.1 test /home/matt/git/github/ekryski/launchpad
> grunt test --stack

Running "jshint:lib" (jshint) task
>> 15 files lint free.

Running "jshint:test" (jshint) task
>> 2 files lint free.

Running "simplemocha:all" (simplemocha) task

  Local browser launcher tests
    Default env settings
[ '', 'not found: chromium-browser\n' ]
[ '/usr/bin/firefox\n', '' ]
      ✓ does local browser and version discovery (167ms)
      ✓ Launches chrome browser on linux
      ✓ Launches firefox browser on linux (586ms)
      ✓ Launches opera browser on linux
      ✓ Launches phantom browser on linux (140ms)
    Custom env settings
      ✓ detects PhantomJS only due to env settings (120ms)

  Remote Preview launcher
    ✓ Writes URL to file

  7 passing (1s)

Done, without errors.

grunt

[launchpad|chromium ↑·3|✚ 1] ./node_modules/grunt-cli/bin/grunt 
Running "jshint:lib" (jshint) task
>> 15 files lint free.

Running "jshint:test" (jshint) task
>> 2 files lint free.

Running "simplemocha:all" (simplemocha) task

  Local browser launcher tests
    Default env settings
[ '/usr/bin/firefox\n', '' ]
[ '/usr/bin/chromium\n',
  'which: no chromium-browser in (/home/matt/.npm-global-packages/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.posix_scripts)\nwhich: no google-chrome in (/home/matt/.npm-global-packages/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.posix_scripts)\nwhich: no google-chrome-stable in (/home/matt/.npm-global-packages/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.posix_scripts)\n' ]
      ✓ does local browser and version discovery (144ms)
      ✓ Launches chrome browser on linux (196ms)
      ✓ Launches firefox browser on linux (661ms)
      ✓ Launches opera browser on linux
      ✓ Launches phantom browser on linux (137ms)
    Custom env settings
      ✓ detects PhantomJS only due to env settings (115ms)

  Remote Preview launcher
    ✓ Writes URL to file

  7 passing (1s)

Done, without errors.

Just keeping this up-to-date with my findings in case I have to come back to this branch.

mattyclarkson commented 8 years ago

Just hangs on Travis now. Will have to come back to this later. Works locally.