Skip to content

Commit

Permalink
refactor: pkg_manager core cli class
Browse files Browse the repository at this point in the history
  • Loading branch information
danpacho committed Aug 10, 2024
1 parent 7ee9cdf commit bf5de6b
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions packages/cli/src/core/pkg_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ export class PkgManager {
}

/**
* @param pkgManager The package manager to use.
* Runs a command using the package manager.
* @param pkgManager - The package manager to use.
* @param commands - The commands to run.
* @param options - The options to use when running the command.
*/
public async install(
public async run(
pkgManager: PkgManagerName,
commands: Array<string>,
options?: {
install?: string
spawn?: Parameters<ShellExecutor['spawn$']>[2]
}
): Promise<void> {
const installCommands: string[] = options?.install
? ['install', options.install]
: ['install']

await this.$shell.spawn$(pkgManager, installCommands, {
await this.$shell.spawn$(pkgManager, commands, {
stdio: 'inherit',
...options?.spawn,
env: {
Expand All @@ -79,4 +78,25 @@ export class PkgManager {
},
})
}

/**
* Installs the dependencies using the package manager.
* @param pkgManager - The package manager to use.
* @param options - The options to use when running the command.
*/
public async install(
pkgManager: PkgManagerName,
options?: {
commands?: string
spawn?: Parameters<ShellExecutor['spawn$']>[2]
}
): Promise<void> {
const installCommands: string[] = options?.commands
? ['install', options.commands]
: ['install']

await this.run(pkgManager, installCommands, {
spawn: options?.spawn,
})
}
}

0 comments on commit bf5de6b

Please sign in to comment.