Sha256: f5986d409ad2466c1407c28a6deece5a5ea3bf7246287299ca2ddef847c5f88c

Contents?: true

Size: 1.77 KB

Versions: 62

Compression:

Stored size: 1.77 KB

Contents

var mout = require('mout');
var Q = require('q');
var endpointParser = require('bower-endpoint-parser');
var PackageRepository = require('../core/PackageRepository');
var Tracker = require('../util/analytics').Tracker;
var defaultConfig = require('../config');

function info(logger, endpoint, property, config) {
    if (!endpoint) {
        return;
    }

    var repository;
    var decEndpoint;
    var tracker;

    config = defaultConfig(config);
    repository = new PackageRepository(config, logger);
    tracker = new Tracker(config);

    decEndpoint = endpointParser.decompose(endpoint);
    tracker.trackDecomposedEndpoints('info', [decEndpoint]);

    return Q.all([
        getPkgMeta(repository, decEndpoint, property),
        decEndpoint.target === '*' && !property ? repository.versions(decEndpoint.source) : null
    ])
    .spread(function (pkgMeta, versions) {
        if (versions) {
            return {
                name: decEndpoint.source,
                versions: versions,
                latest: pkgMeta
            };
        }

        return pkgMeta;
    });
}

function getPkgMeta(repository, decEndpoint, property) {
    return repository.fetch(decEndpoint)
    .spread(function (canonicalDir, pkgMeta) {
        pkgMeta = mout.object.filter(pkgMeta, function (value, key) {
            return key.charAt(0) !== '_';
        });

        // Retrieve specific property
        if (property) {
            pkgMeta = mout.object.get(pkgMeta, property);
        }

        return pkgMeta;
    });
}

// -------------------

info.readOptions = function (argv) {
    var cli = require('../util/cli');
    var options = cli.readOptions(argv);
    var pkg = options.argv.remain[1];
    var property = options.argv.remain[2];

    return [pkg, property];
};

module.exports = info;

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.6.2 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.6.1 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.6 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.19 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.18 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.17 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.16 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.15 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.14 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.13 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.12 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.11 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.10 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.9 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.8 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.7 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.6 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.5 node_modules/bower/lib/commands/info.js
trusty-festivity-extension-2.5.4 node_modules/bower/lib/commands/info.js