Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support a package type "cargo"
- Loading branch information
1 parent
4f1de57
commit 3c4c1d4
Showing
20 changed files
with
164 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package installpackage | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
) | ||
|
||
type CargoPackageInstaller interface { | ||
Install(ctx context.Context, crate, version, root string) error | ||
} | ||
|
||
type MockCargoPackageInstaller struct { | ||
Err error | ||
} | ||
|
||
func (mock *MockCargoPackageInstaller) Install(ctx context.Context, crate, version, root string) error { | ||
return mock.Err | ||
} | ||
|
||
type CargoPackageInstallerImpl struct { | ||
exec Executor | ||
} | ||
|
||
func NewCargoPackageInstallerImpl(exec Executor) *CargoPackageInstallerImpl { | ||
return &CargoPackageInstallerImpl{ | ||
exec: exec, | ||
} | ||
} | ||
|
||
func (inst *CargoPackageInstallerImpl) Install(ctx context.Context, crate, version, root string) error { | ||
_, err := inst.exec.Exec(ctx, "cargo", "install", "--version", version, "--root", root, crate) | ||
if err != nil { | ||
return fmt.Errorf("install a crate: %w", err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.