module.exports = exports;

var log = require('npmlog')
  , cp = require('child_process')

module.exports.validate = function(opts,callback) {
    var args = [];
    var options = {}
    var shell_cmd;
    var arch_names = {
        'ia32':'-i386',
        'x64':'-x86_64'
    }
    var nw = (opts.runtime && opts.runtime === 'node-webkit'); 
    if (nw) {
        options.timeout = 5000;
        if (process.platform === 'darwin') {
            shell_cmd = 'node-webkit';
        } else if (process.platform === 'win32') {
            shell_cmd = 'nw.exe';
        } else {
            shell_cmd = 'nw';
        }
    } else if (process.platform === 'darwin' && arch_names[opts.target_arch]) {
        shell_cmd = 'arch';
        args.push(arch_names[opts.target_arch]);
        args.push(process.execPath);
    } else if (process.arch == opts.target_arch) {
        shell_cmd = process.execPath;
    }
    if (!shell_cmd) {
        return callback();
    }
    args.push(opts.module_main);
    log.info("validate","Running test command: '" + shell_cmd + ' ' + args.join(' ') + "'");
    cp.execFile(shell_cmd, args, options, function(err, stdout, stderr) {
        // check for normal timeout for node-webkit
        if (err && nw && err.killed == true && err.signal.indexOf('SIG') > -1) {
            return callback();
        }
        if (err || stderr) {
            return callback(new Error(err && err.message || stderr));
        }
        return callback();
    });
}

@@ -899,38 +899,13 @@
    %7D
-%0A    if (!shell_cmd) %7B%0A       
+ else
  ret
@@ -920,22 +920,16 @@
 back();%0A
-    %7D%0A
     args

simplify `return callback()` alternative