How to use the cordova-lib.cordova.platform function in cordova-lib

To help you get started, we’ve selected a few cordova-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phonegap / phonegap-cli / lib / phonegap / run.js View on Github external
if (!platform) {
        var platarg = options.platforms[0];
        self.phonegap.emit('error', {message:PG_STR.platerr[0]+platarg+PG_STR.platerr[1]+ platarg + PG_STR.platerr[2]});
        return; 
    }

    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;

    // detect the platform support
    self.phonegap.emit('log', 'detecting', platform.human, 'SDK environment...');

    try {
        // will throw if element in options.platforms isn't recognized
        cordova.platform('', options.platforms, null)
        // invoke local build
        var env = 'local';
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].run(options, callback);
    } catch (e) {
        // invoke remote build
        var env = 'remote';
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].run(options, callback);
    };
};
github phonegap / phonegap-cli / lib / phonegap / install.js View on Github external
callback(new Error(msg));
        return;
    }

    
    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;

    self.phonegap.emit('log', PG_STR.msgdet[0], platform.human, PG_STR.msgdet[1]);

    try {
        // will throw if element in options.platform isn't recognized
        installed = project.listPlatforms('.');
        if (!(options.platforms[0] in installed)) {
            cordova.platform('add', options.platforms, null, function(e){
                // invoke local build
                install.apply(self, ['local', options, callback]);
            });
        }
   } catch (e) {
        // invoke remote build
        install.apply(self, ['remote', options, callback]);
    }
};
github phonegap / phonegap-cli / lib / phonegap / build.js View on Github external
env = '';

    if (!platform) {
        var platarg = options.platforms[0];
        self.phonegap.emit('error', {message:PG_STR.platerr[0]+platarg+PG_STR.platerr[1]+ platarg + PG_STR.platerr[2]});
        return;
    }

    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;

    self.phonegap.emit('log', PG_STR.msgdet[0], platform.human, PG_STR.msgdet[1]);

    // detect the platform support
    try {
        cordova.platform('.', platform.local, null);
        // invoke local or remote build
        var env = 'local';
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].build(options, callback);
    } catch (e) {
        var env = 'remote';
        // emit a non-exiting message to stderr, incase user wants to react to local build failure
        self.phonegap.emit('error', e);
        self.phonegap.emit('log', PG_STR.useenv[0], env, PG_STR.useenv[1]);
        self.phonegap[env].build(options, callback);
    };
};
github phonegap / phonegap-cli / lib / phonegap / platform.update.js View on Github external
// validate parameters
    if (options.platforms.length < 1) {
        var e = new Error('missing a platform to update');
        self.phonegap.emit('error', e);
        callback(e);
        return;
    }

    // change to project directory and delegate errors
    if (!project.cd({ emitter: self.phonegap, callback: callback })) return;
for (each in self.phonegap.version())
{ self.phonegap.emit('log', each);}
    self.phonegap.emit('log', 'updating ' + platform.human + ' platform using PhoneGap CLI version ' + project.readPackage().version );

    // update the platform
    cordova.platform('update', [ platform.local ], function(e) {
        if (e) {
            self.phonegap.emit('error', e);
            callback(e);
            return;
        }

        self.phonegap.emit('log', 'successfully update', platform.human, 'platform');
        callback(null);
    });
};