benderjs / browser-launcher2

☠ This package is no longer maintained ☠
Other
24 stars 13 forks source link

On Windows, it detects Chrome stable, but launches Chrome-Canary #40

Open jakub-g opened 9 years ago

jakub-g commented 9 years ago

Windows 7 64-bit, node 0.10.40 / 0.12.7, Chrome stable (45) and Canary (47) installed

When I run the following code:

var launcher = require("browser-launcher2");

launcher.detect( function( available ) {
    // console.log( 'Available browsers:' );
    // console.dir( available );

    console.log( 'Available Chromes:' );
    console.dir( available.filter(function(item){
        return item.name == 'chrome'
    }) );

    launcher( function( err, launch ) {
        if ( err ) {
            return console.error( err );
        }
        launch( 'http://example.org/', 'chrome', function( err, instance ) {
            if ( err ) {
                return console.error( err );
            }

            console.log( 'Instance started with PID:', instance.pid );

            instance.on( 'stop', function( code ) {
                console.log( 'Instance stopped with exit code:', code );
            } );
        } );
    } );
} );

the output is

$ node bug.js
Available Chromes:
[ { name: 'chrome',
    version: '45.0.2454.85',
    type: 'chrome',
    command: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe' } ]
Instance started with PID: 7960
Instance stopped with exit code: 0

(it detects Chrome stable)

But then, Chrome Canary windows pops out on screen.

So it seems that detection logic and launch logic is different

jakub-g commented 9 years ago

Ah, well, it's once again the caching issue.

I looked up ~/.config/browser-launcher2/config.json and it contained Canary entry, apart from regular Chrome entry, and somehow the tool decided to use Canary instead of stable in this case.

Deleted it, and now the file was recreated but without Canary entry.

I will need to dig further to understand what's going on.