Пример #1
0
/**
 * Deploy specified app package to connected device
 * using ios-deploy command
 * @param  {String} appPath Path to application package
 * @return {Promise}        Resolves when deploy succeeds otherwise rejects
 */
function deployToDevice (appPath, target, extraArgs) {
    events.emit('log', 'Deploying to device');
    // Deploying to device...
    if (target) {
        return superspawn.spawn('ios-deploy', ['--justlaunch', '-d', '-b', appPath, '-i', target].concat(extraArgs), { printCommand: true, stdio: 'inherit' });
    } else {
        return superspawn.spawn('ios-deploy', ['--justlaunch', '--no-wifi', '-d', '-b', appPath].concat(extraArgs), { printCommand: true, stdio: 'inherit' });
    }
}
Пример #2
0
// Execute using a child_process exec, for any async command
function execSpawn (command, args, resultMsg, errorMsg) {
    return superspawn.spawn(command, args).then(function (result) {
        return resultMsg + result;
    }, function (error) {
        return errorMsg + error;
    });
}
        Q.all(platforms_on_fs.map(function(p) {
            var d = Q.defer(),
                d_avail = Q.defer(),
                d_cur = Q.defer();
            add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
            .then(function() {
                superspawn.maybeSpawn(path.join(scratch, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
                .then(function(avail) {
                    if (!avail) {
                        /* Platform version script was silent, we can't work with this */
                        d_avail.resolve('version-empty');
                    } else {
                        d_avail.resolve(avail);
                    }
                })
                .catch(function () {
                    /* Platform version script failed, we can't work with this */
                    d_avail.resolve('version-failed');
                });
            }).catch(function () {
                /* If a platform doesn't install, then we can't realistically suggest updating */
                d_avail.resolve('install-failed');
            });

            superspawn.maybeSpawn(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
            .then(function(v) {
                d_cur.resolve(v || '');
            }).catch(function () {
                d_cur.resolve('broken');
            });

            Q.all([d_avail.promise, d_cur.promise]).spread(function (avail, v) {
                var m, prefix = p + ' @ ' + (v || 'unknown');
                switch (avail) {
                case 'install-failed':
                    m = prefix + '; current did not install, and thus its version cannot be determined';
                    break;
                case 'version-failed':
                    m = prefix + '; current version script failed, and thus its version cannot be determined';
                    break;
                case 'version-empty':
                    m = prefix + '; current version script failed to return a version, and thus its version cannot be determined';
                    break;
                default:
                    if (!v || v === 'broken' || semver.gt(avail, v)) {
                        m = prefix + ' could be updated to: ' + avail;
                    }
                }
                if (m) {
                    platformsText.push(m);
                }
                d.resolve(m);
            })
            .catch(function () {
                d.resolve(p + ' ?');
            })
            .done();

            return d.promise;
        })).then(function() {
Пример #4
0
module.exports.list_targets_with_sdkmanager = function() {
    return superspawn.spawn('sdkmanager', ['--list'])
    .then(function(stdout) {
        var parsing_installed_packages = false;
        var lines = stdout.split('\n');
        var targets = [];
        for (var i = 0, l = lines.length; i < l; i++) {
            var line = lines[i];
            if (line.match(/Installed packages/)) {
                parsing_installed_packages = true;
            } else if (line.match(/Available Packages/) || line.match(/Available Updates/)) {
                // we are done working through installed packages, exit
                break;
            }
            if (parsing_installed_packages) {
                // Match stock android platform
                if (line.match(/platforms;android-\d+/)) {
                    targets.push(line.match(/(android-\d+)/)[1]);
                }
                // Match Google APIs
                if (line.match(/addon-google_apis-google-\d+/)) {
                    var description = lines[i + 1];
                    // munge description to match output from old android sdk tooling
                    var api_level = description.match(/Android (\d+)/); //[1];
                    if (api_level) {
                        targets.push('Google Inc.:Google APIs:' + api_level[1]);
                    }
                }
                // TODO: match anything else?
            }
        }
        return targets;
    });
};
Пример #5
0
 .then(function () {
     return superspawn.spawn('npm', viewArgs)
         .then(function (info) {
             var pluginInfo = JSON.parse(info);
             return pluginInfo;
         });
 });
Пример #6
0
module.exports.list_images_using_avdmanager = function () {
    return superspawn.spawn('avdmanager', ['list', 'avd'])
    .then(function(output) {
        var response = output.split('\n');
        var emulator_list = [];
        for (var i = 1; i < response.length; i++) {
            // To return more detailed information use img_obj
            var img_obj = {};
            if (response[i].match(/Name:\s/)) {
                img_obj['name'] = response[i].split('Name: ')[1].replace('\r', '');
                if (response[i + 1].match(/Device:\s/)) {
                    i++;
                    img_obj['device'] = response[i].split('Device: ')[1].replace('\r', '');
                }
                if (response[i + 1].match(/Path:\s/)) {
                    i++;
                    img_obj['path'] = response[i].split('Path: ')[1].replace('\r', '');
                }
                if (response[i + 1].match(/Target:\s/)) {
                    i++;
                    if (response[i + 1].match(/ABI:\s/)) {
                        img_obj['abi'] = response[i + 1].split('ABI: ')[1].replace('\r', '');
                    }
                    // This next conditional just aims to match the old output of `android list avd`
                    // We do so so that we don't have to change the logic when parsing for the
                    // best emulator target to spawn (see below in `best_image`)
                    // This allows us to transitionally support both `android` and `avdmanager` binaries,
                    // depending on what SDK version the user has
                    if (response[i + 1].match(/Based\son:\s/)) {
                        img_obj['target'] = response[i + 1].split('Based on:')[1];
                        if (img_obj['target'].match(/Tag\/ABI:\s/)) {
                            img_obj['target'] = img_obj['target'].split('Tag/ABI:')[0].replace('\r', '').trim();
                            if (img_obj['target'].indexOf('(') > -1) {
                                img_obj['target'] = img_obj['target'].substr(0, img_obj['target'].indexOf('(') - 1).trim();
                            }
                        }
                        var version_string = img_obj['target'].replace(/Android\s+/, '');

                        var api_level = android_sdk.version_string_to_api_level[version_string];
                        if (api_level) {
                            img_obj['target'] += ' (API level ' + api_level + ')';
                        }
                    }
                }
                if (response[i + 1].match(/Skin:\s/)) {
                    i++;
                    img_obj['skin'] = response[i].split('Skin: ')[1].replace('\r', '');
                }

                emulator_list.push(img_obj);
            }
            /* To just return a list of names use this
            if (response[i].match(/Name:\s/)) {
                emulator_list.push(response[i].split('Name: ')[1].replace('\r', '');
            }*/

        }
        return emulator_list;
    });
};
Пример #7
0
                    .then(function () {
                        // Unpack IPA
                        var ipafile = path.join(buildOutputDir, projectName + '.ipa');

                        // unpack the existing platform/ios/build/device/appname.ipa (zipfile), will create a Payload folder
                        return superspawn.spawn('unzip', [ '-o', '-qq', ipafile ], { cwd: buildOutputDir, printCommand: true, stdio: 'inherit' });
                    })
Пример #8
0
 .then(function() {
     if (needsGitCheckout){
         return superspawn.spawn('git', ['checkout', git_ref], {
             cwd: tmp_dir
         });
     }
 })
Пример #9
0
 return Q.all(platforms_on_fs.map(function(p) {
     return superspawn.maybeSpawn(path.join(project_dir, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
     .then(function(v) {
         result[p] = v || null;
     }, function(v) {
         result[p] = 'broken';
     });
 })).then(function() {
Пример #10
0
module.exports.check_ant = function() {
    return superspawn.spawn('ant', ['-version'])
    .then(function(output) {
        // Parse Ant version from command output
        return /version ((?:\d+\.)+(?:\d+))/i.exec(output)[1];
    }).catch(function(err) {
        throw new CordovaError('Failed to run `ant -version`. Make sure you have `ant` on your $PATH.');
    });
};
Пример #11
0
module.exports.list_targets = function () {
    return superspawn.spawn('android', ['list', 'targets'], {cwd: os.tmpdir()}).then(function (output) {
        var target_out = output.split('\n');
        var targets = [];
        for (var i = target_out.length; i >= 0; i--) {
            if (target_out[i].match(/id:/)) {
                targets.push(targets[i].split(' ')[1]);
            }
        }
        return targets;
    });
};
Пример #12
0
GradleBuilder.prototype.runGradleWrapper = function (gradle_cmd, gradle_file) {
    var gradlePath = path.join(this.root, 'gradlew');
    gradle_file = path.join(this.root, (gradle_file || 'wrapper.gradle'));
    if (fs.existsSync(gradlePath)) {
        // Literally do nothing, for some reason this works, while !fs.existsSync didn't on Windows
    } else {
        return superspawn.spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', gradle_file], { stdio: 'pipe' })
            .progress(function (stdio) {
                suppressJavaOptionsInfo(stdio);
            });
    }
};
Пример #13
0
module.exports.list_targets_with_android = function() {
    return superspawn.spawn('android', ['list', 'targets'])
    .then(function(stdout) {
        var target_out = stdout.split('\n');
        var targets = [];
        for (var i = target_out.length - 1; i >= 0; i--) {
            if(target_out[i].match(/id:/)) {
                targets.push(target_out[i].match(/"(.+)"/)[1]);
            }
        }
        return targets;
    });
};
Пример #14
0
module.exports.create_image = function (name, target) {
    console.log('Creating new avd named ' + name);
    if (target) {
        return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', target]).then(null, function (error) {
            console.error('ERROR : Failed to create emulator image : ');
            console.error(' Do you have the latest android targets including ' + target + '?');
            console.error(error);
        });
    } else {
        console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.');
        // TODO: there's a more robust method for finding targets in android_sdk.js
        return superspawn.spawn('android', ['create', 'avd', '--name', name, '--target', this.list_targets()[0]]).then(function () {
            // TODO: This seems like another error case, even though it always happens.
            console.error('ERROR : Unable to create an avd emulator, no targets found.');
            console.error('Ensure you have targets available by running the "android" command');
            return Q.reject();
        }, function (error) {
            console.error('ERROR : Failed to create emulator image : ');
            console.error(error);
        });
    }
};
Пример #15
0
 return Q().then(function () {
     if (hasJavaHome) {
         // Windows java installer doesn't add javac to PATH, nor set JAVA_HOME (ugh).
         if (!javacPath) {
             process.env['PATH'] += path.delimiter + path.join(process.env['JAVA_HOME'], 'bin');
         }
     } else {
         if (javacPath) {
             // OS X has a command for finding JAVA_HOME.
             var find_java = '/usr/libexec/java_home';
             var default_java_error_msg = 'Failed to find \'JAVA_HOME\' environment variable. Try setting it manually.';
             if (fs.existsSync(find_java)) {
                 return superspawn.spawn(find_java).then(function (stdout) {
                     process.env['JAVA_HOME'] = stdout.trim();
                 }).catch(function (err) {
                     if (err) {
                         throw new CordovaError(default_java_error_msg);
                     }
                 });
             } else {
                 // See if we can derive it from javac's location.
                 // fs.realpathSync is require on Ubuntu, which symplinks from /usr/bin -> JDK
                 var maybeJavaHome = path.dirname(path.dirname(javacPath));
                 if (fs.existsSync(path.join(maybeJavaHome, 'lib', 'tools.jar'))) {
                     process.env['JAVA_HOME'] = maybeJavaHome;
                 } else {
                     throw new CordovaError(default_java_error_msg);
                 }
             }
         } else if (module.exports.isWindows()) {
             // Try to auto-detect java in the default install paths.
             var oldSilent = shelljs.config.silent;
             shelljs.config.silent = true;
             var firstJdkDir =
                 shelljs.ls(process.env['ProgramFiles'] + '\\java\\jdk*')[0] ||
                 shelljs.ls('C:\\Program Files\\java\\jdk*')[0] ||
                 shelljs.ls('C:\\Program Files (x86)\\java\\jdk*')[0];
             shelljs.config.silent = oldSilent;
             if (firstJdkDir) {
                 // shelljs always uses / in paths.
                 firstJdkDir = firstJdkDir.replace(/\//g, path.sep);
                 if (!javacPath) {
                     process.env['PATH'] += path.delimiter + path.join(firstJdkDir, 'bin');
                 }
                 process.env['JAVA_HOME'] = firstJdkDir;
             }
         }
     }
 }).then(function () {
 .then(function() {
     superspawn.maybeSpawn(path.join(scratch, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
     .then(function(avail) {
         if (!avail) {
             /* Platform version script was silent, we can't work with this */
             d_avail.resolve('version-empty');
         } else {
             d_avail.resolve(avail);
         }
     })
     .catch(function () {
         /* Platform version script failed, we can't work with this */
         d_avail.resolve('version-failed');
     });
 }).catch(function () {
Пример #17
0
module.exports.run = function () {
    var projectName = shell.ls(projectPath).filter(function (name) {
        return path.extname(name) === '.xcodeproj';
    })[0];

    if (!projectName) {
        return Q.reject('No Xcode project found in ' + projectPath);
    }

    return superspawn.spawn('xcodebuild', ['-project', projectName, '-configuration', 'Debug', '-alltargets', 'clean'], { cwd: projectPath, printCommand: true, stdio: 'inherit' })
        .then(function () {
            return superspawn.spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], { cwd: projectPath, printCommand: true, stdio: 'inherit' });
        }).then(function () {
            return shell.rm('-rf', path.join(projectPath, 'build'));
        });
};
Пример #18
0
function iossimLaunch (appPath, devicetypeid, log, exit) {
    var f = path.resolve(path.dirname(require.resolve('ios-sim')), 'bin', 'ios-sim');
    var params = ['launch', appPath, '--devicetypeid', devicetypeid, '--log', log, exit];

    return superspawn.spawn(f, params, { cwd: projectPath, printCommand: true })
        .progress(function (stdio) {
            if (stdio.stderr) {
                events.emit('error', `[ios-sim] ${stdio.stderr}`);
            }
            if (stdio.stdout) {
                events.emit('log', `[ios-sim] ${stdio.stdout.trim()}`);
            }
        })
        .then(function (result) {
            events.emit('log', 'Simulator successfully started via `ios-sim`.');
        });
}
Пример #19
0
    .then(function() {    
        if(dest && target) {
            //add target to fetchArgs Array
            fetchArgs.push(target);  
        } else return Q.reject(new CordovaError('Need to supply a target and destination'));

        //set the directory where npm uninstall will be run
        opts.cwd = dest;

        //if user added --save flag, pass it to npm uninstall command
        if(opts.save) {
            fetchArgs.push('--save'); 
        }

        //run npm uninstall, this will remove dependency
        //from package.json if --save was used.
        return superspawn.spawn('npm', fetchArgs, opts);
    })
Пример #20
0
GradleBuilder.prototype.build = function (opts) {
    var wrapper = path.join(this.root, 'gradlew');
    var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);

    return superspawn.spawn(wrapper, args, { stdio: 'pipe' })
        .progress(function (stdio) {
            suppressJavaOptionsInfo(stdio);
        }).catch(function (error) {
            if (error.toString().indexOf('failed to find target with hash string') >= 0) {
                return check_reqs.check_android_target(error).then(function () {
                    // If due to some odd reason - check_android_target succeeds
                    // we should still fail here.
                    return Q.reject(error);
                });
            }
            return Q.reject(error);
        });
};
Пример #21
0
module.exports.list_images_using_android = function() {
    return superspawn.spawn('android', ['list', 'avds'])
    .then(function(output) {
        var response = output.split('\n');
        var emulator_list = [];
        for (var i = 1; i < response.length; i++) {
            // To return more detailed information use img_obj
            var img_obj = {};
            if (response[i].match(/Name:\s/)) {
                img_obj['name'] = response[i].split('Name: ')[1].replace('\r', '');
                if (response[i + 1].match(/Device:\s/)) {
                    i++;
                    img_obj['device'] = response[i].split('Device: ')[1].replace('\r', '');
                }
                if (response[i + 1].match(/Path:\s/)) {
                    i++;
                    img_obj['path'] = response[i].split('Path: ')[1].replace('\r', '');
                }
                if (response[i + 1].match(/\(API\slevel\s/) || (response[i + 2] && response[i + 2].match(/\(API\slevel\s/))) {
                    i++;
                    var secondLine = response[i + 1].match(/\(API\slevel\s/) ? response[i + 1] : '';
                    img_obj['target'] = (response[i] + secondLine).split('Target: ')[1].replace('\r', '');
                }
                if (response[i + 1].match(/ABI:\s/)) {
                    i++;
                    img_obj['abi'] = response[i].split('ABI: ')[1].replace('\r', '');
                }
                if (response[i + 1].match(/Skin:\s/)) {
                    i++;
                    img_obj['skin'] = response[i].split('Skin: ')[1].replace('\r', '');
                }

                emulator_list.push(img_obj);
            }
            /* To just return a list of names use this
            if (response[i].match(/Name:\s/)) {
                emulator_list.push(response[i].split('Name: ')[1].replace('\r', '');
            }*/

        }
        return emulator_list;
    });
};
/**
 * Runs script using child_process spawn method.
 * Returns a promise. */
function runScriptViaChildProcessSpawn(script, context) {
    var opts = context.opts;
    var command = script.fullPath;
    var args = [opts.projectRoot];

    if (fs.statSync(script.fullPath).isDirectory()) {
        events.emit('verbose', 'skipped directory "' + script.fullPath + '" within hook directory');
        return Q();
    }

    if (isWindows) {
        // TODO: Make shebang sniffing a setting (not everyone will want this).
        var interpreter = extractSheBangInterpreter(script.fullPath);
        // we have shebang, so try to run this script using correct interpreter
        if (interpreter) {
            args.unshift(command);
            command = interpreter;
        }
    }

    var execOpts = {cwd: opts.projectRoot, printCommand: true, stdio: 'inherit'};
    execOpts.env = {};
    execOpts.env.CORDOVA_VERSION = require('../../package').version;
    execOpts.env.CORDOVA_PLATFORMS = opts.platforms ? opts.platforms.join() : '';
    execOpts.env.CORDOVA_PLUGINS = opts.plugins ? opts.plugins.join() : '';
    execOpts.env.CORDOVA_HOOK = script.fullPath;
    execOpts.env.CORDOVA_CMDLINE = process.argv.join(' ');

    return superspawn.spawn(command, args, execOpts)
        .catch(function(err) {
            // Don't treat non-executable files as errors. They could be READMEs, or Windows-only scripts.
            if (!isWindows && err.code == 'EACCES') {
                events.emit('verbose', 'skipped non-executable file: ' + script.fullPath);
            } else {
                throw new Error('Hook failed with error code ' + err.code + ': ' + script.fullPath);
            }
        });
}
Пример #23
0
//  clone_dir, if provided is the directory that git will clone into.
//  if no clone_dir is supplied, a temp directory will be created and used by git.
function clone(git_url, git_ref, clone_dir){
    
    var needsGitCheckout = !!git_ref;
    if (!shell.which('git')) {
        return Q.reject(new Error('"git" command line tool is not installed: make sure it is accessible on your PATH.'));
    }

    // If no clone_dir is specified, create a tmp dir which git will clone into.
    var tmp_dir = clone_dir;
    if(!tmp_dir){
        tmp_dir = path.join(os.tmpdir(), 'git', String((new Date()).valueOf()));
    }
    shell.rm('-rf', tmp_dir);
    shell.mkdir('-p', tmp_dir);
    
    var cloneArgs = ['clone', '--recursive'];
    if(!needsGitCheckout) {
        // only get depth of 1 if there is no branch/commit specified
        cloneArgs.push('--depth=1');
    }
    cloneArgs.push(git_url, tmp_dir);
    return superspawn.spawn('git', cloneArgs)
    .then(function() {
        if (needsGitCheckout){
            return superspawn.spawn('git', ['checkout', git_ref], {
                cwd: tmp_dir
            });
        }
    })
    .then(function(){
        events.emit('log', 'Repository "' + git_url + '" checked out to git ref "' + (git_ref || 'master') + '".');
        return tmp_dir;
    })
    .fail(function (err) {
        shell.rm('-rf', tmp_dir);
        return Q.reject(err);
    });
}
Пример #24
0
    .then(function(depTree) {
        tree1 = depTree;

        //install new module
        return superspawn.spawn('npm', fetchArgs, opts);
    })
Пример #25
0
 return Q().then(function () {
     return superspawn.spawn(wrapper, args, { stdio: 'inherit' });
 }).then(function () {
Пример #26
0
function displayVirtualDevices (projectRoot, platform, options) {
    var caller = { 'script': 'list-emulator-images' };
    events.emit('log', 'Available ' + platform + ' virtual devices:');
    var cmd = path.join(projectRoot, 'platforms', platform, 'cordova', 'lib', 'list-emulator-images');
    return superspawn.spawn(cmd, options.argv, { stdio: 'inherit', chmod: true }).catch(handleError.bind(caller));
}
Пример #27
0
 return Q().then(function() {
     if (options.platformVersion) {
         return Q(options.platformVersion);
     }
     return Q(superspawn.maybeSpawn(path.join(project_dir, 'cordova', 'version'), [], { chmod: true }));
 }).then(function(platformVersion) {
Пример #28
0
module.exports.list_targets_with_android = function () {
    return superspawn.spawn('android', ['list', 'target']).then(parse_targets);
};
function check(hooksRunner, projectRoot) {
    var platformsText = [],
        platforms_on_fs = cordova_util.listPlatforms(projectRoot),
        scratch = path.join(os.tmpdir(), 'cordova-platform-check-' + Date.now()),
        listeners = events._events;
    events._events = {};
    var result = Q.defer();
    var updateCordova = Q.defer();
    superspawn.spawn('npm',
                     ['--loglevel=silent', '--json', 'outdated', 'cordova-lib'],
                     {cwd: path.dirname(require.main.filename)}
                    ).then(
        function (output) {
            var vers;
            try {
                var json = JSON.parse(output)['cordova-lib'];
                vers = [json.latest, json.current];
            } catch (e) {
                vers = ('' || output).match(/cordova-lib@(\S+)\s+\S+\s+current=(\S+)/);
            }
            if (vers) {
                updateCordova.resolve([vers[1], vers[2]]);
            } else {
                updateCordova.resolve();
            }
        }
    ).catch(function (){
        /* oh well */
        updateCordova.resolve();
    });
    cordova.raw.create(scratch)
    .then(function () {
        var h = new HooksRunner(scratch);
        // Acquire the version number of each platform we have installed, and output that too.
        Q.all(platforms_on_fs.map(function(p) {
            var d = Q.defer(),
                d_avail = Q.defer(),
                d_cur = Q.defer();
            add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
            .then(function() {
                superspawn.maybeSpawn(path.join(scratch, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
                .then(function(avail) {
                    if (!avail) {
                        /* Platform version script was silent, we can't work with this */
                        d_avail.resolve('version-empty');
                    } else {
                        d_avail.resolve(avail);
                    }
                })
                .catch(function () {
                    /* Platform version script failed, we can't work with this */
                    d_avail.resolve('version-failed');
                });
            }).catch(function () {
                /* If a platform doesn't install, then we can't realistically suggest updating */
                d_avail.resolve('install-failed');
            });

            superspawn.maybeSpawn(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), [], { chmod: true })
            .then(function(v) {
                d_cur.resolve(v || '');
            }).catch(function () {
                d_cur.resolve('broken');
            });

            Q.all([d_avail.promise, d_cur.promise]).spread(function (avail, v) {
                var m, prefix = p + ' @ ' + (v || 'unknown');
                switch (avail) {
                case 'install-failed':
                    m = prefix + '; current did not install, and thus its version cannot be determined';
                    break;
                case 'version-failed':
                    m = prefix + '; current version script failed, and thus its version cannot be determined';
                    break;
                case 'version-empty':
                    m = prefix + '; current version script failed to return a version, and thus its version cannot be determined';
                    break;
                default:
                    if (!v || v === 'broken' || semver.gt(avail, v)) {
                        m = prefix + ' could be updated to: ' + avail;
                    }
                }
                if (m) {
                    platformsText.push(m);
                }
                d.resolve(m);
            })
            .catch(function () {
                d.resolve(p + ' ?');
            })
            .done();

            return d.promise;
        })).then(function() {
            var results = '';
            var resultQ = Q.defer();
            events._events = listeners;
            shell.rm('-rf', scratch);
            updateCordova.promise.then(function (versions) {
                var message = '';
                if (versions && semver.gt(versions[0], versions[1])) {
                    message = 'An update of cordova is available: ' + versions[0] + '\n';
                }
                resultQ.promise.then(function (output) {
                    var results = message + output;
                    events.emit('results', results);
                    result.resolve();
                });
            });
            if (platformsText) {
                results = platformsText.filter(function (p) { return !!p; }).sort().join('\n');
            }
            if (!results) {
                results = 'No platforms can be updated at this time.';
            }
            resultQ.resolve(results);
        })
        .done();
    }).catch(function (){
        events._events = listeners;
        shell.rm('-rf', scratch);
    })
    .done();
    return result.promise;
}
Пример #30
0
module.exports.list_targets_with_avdmanager = function () {
    return superspawn.spawn('avdmanager', ['list', 'target']).then(parse_targets);
};