"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shell_1 = require("../shell");
class PackageManager {
    async installAll(options) {
        // TODO get package manager (could be yarn)
        await shell_1.shell.execSpawn(`npm`, ['install'], options);
    }
    async installFromConfig(packageJson) {
        await this._installDependencies(packageJson.dependencies);
        await this._installDependencies(packageJson.devDependencies);
        await this._installDependencies(packageJson.optionalDependencies).catch(err => { });
    }
    async _installDependencies(dependencies) {
        await shell_1.shell.execSpawn(`npm`, [
            'install',
            ...Object.keys(dependencies).map(key => `${key}@${dependencies[key]}`)
        ]);
    }
}
exports.PackageManager = PackageManager;
exports.packageManager = new PackageManager();
//# sourceMappingURL=package-manager.js.map