'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());
    });
};
let argv = process.argv.slice(2);
if (argv.indexOf('--help') !== -1 || argv.indexOf('-h') !== -1 || argv.indexOf('--h') !== -1) {
    argv = ['help'].concat(argv);
}
(() => __awaiter(this, void 0, void 0, function* () {
    switch (argv[0]) {
        case '-v':
        case '--version':
            const pkg = (yield Promise.resolve().then(() => require('../pnpmPkgJson'))).default;
            console.log(pkg.version);
            break;
        case 'help':
            const help = (yield Promise.resolve().then(() => require('../cmd/help'))).default;
            help(argv.slice(1));
            break;
        // commands that are passed through to npm:
        case 'access':
        case 'adduser':
        case 'bin':
        case 'bugs':
        case 'c':
        case 'config':
        case 'deprecate':
        case 'dist-tag':
        case 'docs':
        case 'edit':
        case 'get':
        case 'info':
        case 'init':
        case 'login':
        case 'logout':
        case 'owner':
        case 'pack':
        case 'ping':
        case 'prefix':
        case 'profile':
        case 'publish':
        case 'repo':
        case 'restart':
        case 's':
        case 'se':
        case 'search':
        case 'set':
        case 'star':
        case 'stars':
        case 'start':
        case 'stop':
        case 'team':
        case 'token':
        case 'unpublish':
        case 'unstar':
        case 'v':
        case 'version':
        case 'view':
        case 'whoami':
        case 'xmas':
            yield passThruToNpm();
            break;
        case 't':
        case 'tst':
        case 'test':
        case 'run':
        case 'run-script':
            if (argv.indexOf('--filter') !== -1) {
                yield runPnpm();
            }
            else {
                yield passThruToNpm();
            }
            break;
        default:
            yield runPnpm();
            break;
    }
}))();
function runPnpm() {
    return __awaiter(this, void 0, void 0, function* () {
        const errorHandler = (yield Promise.resolve().then(() => require('../err'))).default;
        try {
            const main = (yield Promise.resolve().then(() => require('../main'))).default;
            yield main(argv);
        }
        catch (err) {
            errorHandler(err);
        }
    });
}
function passThruToNpm() {
    return __awaiter(this, void 0, void 0, function* () {
        const runNpm = (yield Promise.resolve().then(() => require('../cmd/runNpm'))).default;
        runNpm(argv);
    });
}
//# sourceMappingURL=pnpm.js.map