How to use the cordova-common.CordovaError function in cordova-common

To help you get started, we’ve selected a few cordova-common 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 weexteam / pack-android-tools-for-Apache-Weex / bin / templates / cordova / lib / pluginHandlers.js View on Github external
uninstall:function(obj, plugin, project, options) {
            var src = obj.src;
            if (!src) throw new CordovaError(generateAttributeError('src', 'framework', plugin.id));

            events.emit('verbose', 'Uninstalling Android library: ' + src);
            var parentDir = obj.parent ? path.resolve(project.projectDir, obj.parent) : project.projectDir;
            var subDir;

            if (obj.custom) {
                var subRelativeDir = project.getCustomSubprojectRelativeDir(plugin.id, src);
                removeFile(project.projectDir, subRelativeDir);
                subDir = path.resolve(project.projectDir, subRelativeDir);
                // If it's the last framework in the plugin, remove the parent directory.
                var parDir = path.dirname(subDir);
                if (fs.existsSync(parDir) && fs.readdirSync(parDir).length === 0) {
                    fs.rmdirSync(parDir);
                }
            } else {
                // WEEX_HOOK
github apache / cordova-windows / template / cordova / lib / build.js View on Github external
'packageThumbprint': String,
        'publisherId': String,
        'buildConfig': String,
        'buildFlag': [String, Array]
    }, {}, options.argv, 0);

    var config = {};
    var buildConfig = {};

    // Validate args
    if (options.debug && options.release) {
        throw new CordovaError('Cannot specify "debug" and "release" options together.');
    }

    if (args.phone && args.win) {
        throw new CordovaError('Cannot specify "phone" and "win" options together.');
    }

    // get build options/defaults
    config.buildType = options.release ? 'release' : 'debug';

    var archs = options.archs || args.archs;
    config.buildArchs = archs ? archs.toLowerCase().split(' ') : ['anycpu'];

    config.phone = !!args.phone;
    config.win = !!args.win;
    config.projVerOverride = args.appx;
    // only set config.bundle if architecture is not anycpu
    if (args.bundle) {
        if (config.buildArchs.length > 1 && (config.buildArchs.indexOf('anycpu') > -1 || config.buildArchs.indexOf('any cpu') > -1)) {
            // Not valid to bundle anycpu with cpu-specific architectures.  warn, then don't bundle
            events.emit('warn', '"anycpu" and CPU-specific architectures were selected. ' +
github apache / cordova-electron / bin / templates / cordova / lib / prepare.js View on Github external
const extension = path.extname(icon.src);
            const suffix = icon.src.split('@').pop().slice(0, -extension.length);

            return Object.assign(icon, { suffix, extension });
        }
    });

    let remainingIcons = findRemainingIcons(icons, highResIcons);
    // set normal image that has standard resolution
    const has1x = highResIcons.find(obj => obj.suffix === '1x');
    if (!has1x && Object.keys(highResIcons).length) {
        const highResIcon = highResIcons[Object.keys(highResIcons)[0]];
        let baseIcon = remainingIcons.find(obj => obj.src === highResIcon.src.split('@')[0] + highResIcon.extension);

        if (!baseIcon) {
            throw new CordovaError('Base icon for high resolution images was not found.');
        }

        const extension = path.extname(baseIcon.src);
        const suffix = '1x';

        baseIcon = Object.assign(baseIcon, { suffix, extension });

        highResIcons.push(baseIcon);

        remainingIcons = findRemainingIcons(icons, highResIcons);
    }

    return { highResIcons, remainingIcons };
}
github alitajs / alita / packages / umi-plugin-cordova / src / create-cordova.ts View on Github external
return Promise.resolve().then(function () {
        if (!dir) {
            throw new CordovaError('Directory not specified. See `cordova help`.');
        }

        if (!isObject(opts)) {
            throw new CordovaError('Given options must be an object');
        }

        // Shallow copy opts
        opts = Object.assign({}, opts);

        events = setupEvents(opts.extEvents);
        events.emit('verbose', 'Using detached cordova-create');

        // Make absolute.
        dir = path.resolve(dir);

        // if (fs.existsSync(dir) && fs.readdirSync(dir).length > 0) {
github qualintitative / egoweb / app / node_modules / cordova-android / bin / templates / cordova / lib / pluginHandlers.js View on Github external
uninstall:function(obj, plugin, project, options) {
            var src = obj.src;
            if (!src) throw new CordovaError(generateAttributeError('src', 'framework', plugin.id));

            events.emit('verbose', 'Uninstalling Android library: ' + src);
            var parentDir = obj.parent ? path.resolve(project.projectDir, obj.parent) : project.projectDir;
            var subDir;

            if (obj.custom) {
                var subRelativeDir = project.getCustomSubprojectRelativeDir(plugin.id, src);
                removeFile(project.projectDir, subRelativeDir);
                subDir = path.resolve(project.projectDir, subRelativeDir);
                // If it's the last framework in the plugin, remove the parent directory.
                var parDir = path.dirname(subDir);
                if (fs.existsSync(parDir) && fs.readdirSync(parDir).length === 0) {
                    fs.rmdirSync(parDir);
                }
            } else {
                obj.type = 'sys';
github katzer / cordova-plugin-badge / platforms / android / cordova / lib / device.js View on Github external
return this.list(true).then(function (device_list) {
        if (!device_list || !device_list.length) {
            return Q.reject(new CordovaError('Failed to deploy to device, no devices found.'));
        }
        // default device
        target = target || device_list[0];

        if (device_list.indexOf(target) < 0) {
            return Q.reject('ERROR: Unable to find target \'' + target + '\'.');
        }

        return build.detectArchitecture(target).then(function (arch) {
            return { target: target, arch: arch, isEmulator: false };
        });
    });
};
github katzer / cordova-plugin-badge / platforms / android / cordova / lib / builders / GradleBuilder.js View on Github external
propertiesObj.systemLibs.forEach(function (p) {
        var mavenRef;
        // It's already in gradle form if it has two ':'s
        if (/:.*:/.exec(p)) {
            mavenRef = p;
        } else {
            for (var i = 0; i < SYSTEM_LIBRARY_MAPPINGS.length; ++i) {
                var pair = SYSTEM_LIBRARY_MAPPINGS[i];
                if (pair[0].exec(p)) {
                    mavenRef = p.replace(pair[0], pair[1]);
                    break;
                }
            }
            if (!mavenRef) {
                throw new CordovaError('Unsupported system library (does not work with gradle): ' + p);
            }
        }
        depsList += '    compile "' + mavenRef + '"\n';
    });
github weexteam / pack-android-tools-for-Apache-Weex / bin / lib / check_reqs.js View on Github external
module.exports.check_gradle = function() {
    var sdkDir = process.env['ANDROID_HOME'];
    if (!sdkDir)
        return Q.reject(new CordovaError('Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.\n' +
            'Might need to install Android SDK or set up \'ANDROID_HOME\' env variable.'));

    var wrapperDir = path.join(sdkDir, 'tools', 'templates', 'gradle', 'wrapper');
    if (!fs.existsSync(wrapperDir)) {
        return Q.reject(new CordovaError('Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.\n' +
            'Looked here: ' + wrapperDir));
    }
    return Q.when();
};
github myFace-KYC / Identity_Verification / node_modules / cordova-android / bin / templates / cordova / lib / pluginHandlers.js View on Github external
function copyNewFile (plugin_dir, src, project_dir, dest, link) {
    var target_path = path.resolve(project_dir, dest);
    if (fs.existsSync(target_path)) { throw new CordovaError('"' + target_path + '" already exists!'); }

    copyFile(plugin_dir, src, project_dir, dest, !!link);
}
github katzer / cordova-plugin-badge / platforms / windows / cordova / lib / PluginHandler.js View on Github external
function copyNewFile (plugin_dir, src, project_dir, dest, link) {
    var target_path = path.resolve(project_dir, dest);
    if (fs.existsSync(target_path))
        throw new CordovaError('"' + target_path + '" already exists!');

    copyFile(plugin_dir, src, project_dir, dest, !!link);
}