Skip to content

Commit

Permalink
feat: add silent mode to PackageManager
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee committed Feb 18, 2019
1 parent df4a154 commit 368b96f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/cli/src/util/PackageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export default class PackageManager {
this.options = options;
}

executeCommand(command: string) {
return execSync(command, { stdio: 'inherit' });
executeCommand(command: string, options?: { silent: boolean }) {
return execSync(command, {
stdio: options && options.silent ? 'pipe' : 'inherit',
});
}

shouldCallYarn() {
Expand All @@ -26,11 +28,12 @@ export default class PackageManager {
);
}

install(packageNames: Array<string>) {
install(packageNames: Array<string>, options?: { silent: boolean }) {
return this.shouldCallYarn()
? this.executeCommand(`yarn add ${packageNames.join(' ')}`)
? this.executeCommand(`yarn add ${packageNames.join(' ')}`, options)
: this.executeCommand(
`npm install ${packageNames.join(' ')} --save --save-exact`
`npm install ${packageNames.join(' ')} --save --save-exact`,
options
);
}

Expand Down

0 comments on commit 368b96f

Please sign in to comment.