Skip to content
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

Default '--version' value? #122

Closed
fritx opened this issue Aug 22, 2015 · 7 comments
Closed

Default '--version' value? #122

fritx opened this issue Aug 22, 2015 · 7 comments
Labels
enhancement Feature request

Comments

@fritx
Copy link

fritx commented Aug 22, 2015

if (!opts.version) return cb(new Error('Must specify version'))

As index.js#L153 it seems that the --version flag is required
But it seems to bring troubles to writing build scripts
Can we auto detect from '~/.electron' directory and fetch the latest version as default?
Or any tips? Thanks. 😄

Also, default '--platform' and '--arch'?

@iamdriz
Copy link

iamdriz commented Sep 1, 2015

Yeah this would awesome! As I have just had an issue where we were building from old versions of Electron as we had the versions hard-coded in the gruntfiles. So to have it default to latest version if none is specified would be perfect.

@fritx
Copy link
Author

fritx commented Sep 1, 2015

Oh it's awesome that i'm just viewing another issue opened by you.. quite a coincidence!

@malept
Copy link
Member

malept commented Sep 8, 2015

You may be interested in PR #94.

@fritx
Copy link
Author

fritx commented Sep 9, 2015

@malept cool

@malept malept added enhancement Feature request help wanted Needs a contributor from the community labels Sep 26, 2015
@sleepygarden
Copy link

I've written a little build.js script which doesn't rely on npm as a module (sort of, it uses the global npm cli) and can pinpoint both the local and latest version and handle timeouts.

function run_cmd(cmd, args, callBack ) {
    var spawn = require('child_process').spawn;
    var child = spawn(cmd, args);
    var resp = "";

    child.stdout.on('data', function (buffer) { resp += buffer.toString() });
    child.stdout.on('end', function() { callBack (resp) });
    return child;
}

function latestElectronVersion(versionCallback){
    var proc, timeout;
    console.log('Looking up latest Electron version...');
    var proc = run_cmd('npm',['view','electron-prebuilt','version'],function(versionString){
        versionCallback(versionString.trim());
        clearTimeout(timeout);
    });
    timeout = setTimeout(function() {
        console.error('Latest Electron version lookup timed out');
        proc.kill();
        process.exit(1);
    }, 1000 * 10); // 10s
}

function localElectronVersion(versionCallback){
    console.log('Looking up local Electron version...');
    run_cmd('npm',['list', 'electron-prebuilt', '--json'], function(json){
        versionCallback(JSON.parse(json).dependencies['electron-prebuilt'].version);
    });
}

I use this as part of my build script, and I plan on moving more build options to my package.json to help center my configs:

var package = require('./package.json');
latestElectronVersion(function(version){
    build({
        'platform': 'darwin',
        'arch': 'x64',
        'version': version,
        'name': package.name,
        'app-version': package.version,
        'dir': './',
        'out': './build',
        'ignore': '\.\/build',
        'overwrite': true,
        'icon': 'Icon.icns',
        'prune' : true
    });
});

but I think it'd make more send to have --version=local and --version=latest options and default to local when none is provided.

@malept
Copy link
Member

malept commented Jan 17, 2016

#94 has been merged, it defaults to the Electron version specified by package.json.

@malept malept closed this as completed Jan 17, 2016
@fritx
Copy link
Author

fritx commented Jan 17, 2016

cool

@malept malept removed the help wanted Needs a contributor from the community label Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request
Projects
None yet
Development

No branches or pull requests

4 participants