"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const npm_1 = require("./npm");
const tarball_1 = require("./tarball");
const local_1 = require("./local");
const git_1 = require("./git");
/**
 * Resolves a package in the NPM registry. Done as part of `install()`.
 *
 * @example
 *     var npa = require('npm-package-arg')
 *     resolve(npa('rimraf@2'))
 *       .then((res) => {
 *         res.id == 'rimraf@2.5.1'
 *         res.dist == {
 *           shasum: '0a1b2c...'
 *           tarball: 'http://...'
 *         }
 *       })
 */
function default_1(spec, opts) {
    return __awaiter(this, void 0, void 0, function* () {
        switch (spec.type) {
            case 'range':
            case 'version':
            case 'tag':
                return npm_1.default(spec, opts);
            case 'remote':
                return tarball_1.default(spec, opts);
            case 'local':
                return local_1.default(spec, opts);
            case 'hosted':
            case 'git':
                return git_1.default(spec, opts);
            default:
                throw new Error(`${spec.rawSpec}: ${spec.type} packages not supported`);
        }
    });
}
exports.default = default_1;
//# sourceMappingURL=index.js.map