UNPKG

@roots/dependencies

Version:

Automated package installation

57 lines (56 loc) 1.32 kB
import { __decorate } from "tslib"; import { bind } from 'helpful-decorators'; import { Command } from './base.command.js'; /** * Npm command */ export class Npm extends Command { /** * Get the latest version of a package from the npm registry */ async getLatestVersion(signifier) { const result = await this.execute([ `npm`, `view`, signifier, `version`, ]); if (result?.shift) return result.shift().trim(); // #todo: this is bad return `latest`; // fallback } /** */ install(dependencies, args = []) { return this.execute([ `npm`, `install`, ...this.normalizeDependencies(dependencies), `--prefix`, this.path, ...args, ]); } /** */ uninstall(dependencies, args = []) { return this.execute([ `npm`, `uninstall`, ...this.normalizeDependencies(dependencies), `--prefix`, this.path, ...args, ]); } } __decorate([ bind ], Npm.prototype, "getLatestVersion", null); __decorate([ bind ], Npm.prototype, "install", null); __decorate([ bind ], Npm.prototype, "uninstall", null);