Skip to content

Commit

Permalink
Merge pull request #42 from LiteLDev/develop
Browse files Browse the repository at this point in the history
Fix failing to update or remove Lip with Lip
  • Loading branch information
futrime authored Feb 5, 2023
2 parents c603052 + 0e75831 commit cabcb37
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
33 changes: 20 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.1] - 2023-02-05

### Fixed

- Failing to hot update or remove Lip in local directory.

## [0.7.0] - 2023-02-01

### Added
Expand Down Expand Up @@ -115,17 +121,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Basic functions: cache, install, list, show, tooth init, and uninstall.

[unreleased]: https://github.com/LiteLDev/Lip/compare/v0.7.0...HEAD
[0.7.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.6.0...v0.7.0
[0.6.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.5.1...v0.6.0
[0.5.1]: https://github.com/LiteLDev/Lip/releases/tag/v0.4.0...v0.5.1
[0.5.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.4.0...v0.5.0
[0.4.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.3.4...v0.4.0
[0.3.4]: https://github.com/LiteLDev/Lip/releases/tag/v0.3.3...v0.3.4
[0.3.3]: https://github.com/LiteLDev/Lip/releases/tag/v0.3.2...v0.3.3
[0.3.2]: https://github.com/LiteLDev/Lip/releases/tag/v0.3.1...v0.3.2
[0.3.1]: https://github.com/LiteLDev/Lip/releases/tag/v0.3.0...v0.3.1
[0.3.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.2.1...v0.3.0
[0.2.1]: https://github.com/LiteLDev/Lip/releases/tag/v0.2.0...v0.2.1
[0.2.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.1.0...v0.2.0
[unreleased]: https://github.com/LiteLDev/Lip/compare/v0.7.1...HEAD
[0.7.1]: https://github.com/LiteLDev/Lip/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/LiteLDev/Lip/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/LiteLDev/Lip/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/LiteLDev/Lip/compare/v0.4.0...v0.5.1
[0.5.0]: https://github.com/LiteLDev/Lip/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/LiteLDev/Lip/compare/v0.3.4...v0.4.0
[0.3.4]: https://github.com/LiteLDev/Lip/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/LiteLDev/Lip/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/LiteLDev/Lip/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/LiteLDev/Lip/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/LiteLDev/Lip/compare/v0.2.1...v0.3.0
[0.2.1]: https://github.com/LiteLDev/Lip/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/LiteLDev/Lip/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/LiteLDev/Lip/releases/tag/v0.1.0
1 change: 1 addition & 0 deletions src/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func Run() {
for _, specifier := range specifiers {
// If the specifier is not a requirement specifier, skip.
if specifier.Type() != RequirementSpecifierType {
logger.Error("the specifier " + specifier.String() + " is not a requirement specifier. It cannot be used with the force-reinstall flag or the upgrade flag")
continue
}

Expand Down
20 changes: 20 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,19 @@ func main() {
err = localfile.Init()
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}

// Change the working directory to the project root.
workspaceDir, err := localfile.WorkSpaceDir()
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}
err = os.Chdir(workspaceDir)
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}

// Attempt to execute .lip/tools/lip or .lip/tools/lip.exe if it exists.
Expand All @@ -52,6 +55,21 @@ func main() {
lipExeName = "lip.exe"
}

// Remove {lipExeName} and lip.remove if they exist.
if _, err := os.Stat(".lip/tools/lip/lip.remove"); err == nil {
logger.Info("Removing .lip/tools/lip/" + lipExeName + " and .lip/tools/lip/lip.remove")
err = os.Remove(".lip/tools/lip/" + lipExeName)
if err != nil {
logger.Error("failed to remove old Lip version: " + err.Error())
os.Exit(1)
}
err = os.Remove(".lip/tools/lip/lip.remove")
if err != nil {
logger.Error("failed to remove old Lip version: " + err.Error())
os.Exit(1)
}
}

// Move lip.update to {lipExeName} if it exists.
if _, err := os.Stat(".lip/tools/lip/lip.update"); err == nil {
logger.Info("Moving .lip/tools/lip/lip.update to .lip/tools/lip/" + lipExeName)
Expand All @@ -61,13 +79,15 @@ func main() {
err = os.Remove(".lip/tools/lip/" + lipExeName)
if err != nil {
logger.Error("failed to remove old Lip version: " + err.Error())
os.Exit(1)
}
}

// Move the new {lipExeName}.
err = os.Rename(".lip/tools/lip/lip.update", ".lip/tools/lip/"+lipExeName)
if err != nil {
logger.Error("failed to move new Lip version: " + err.Error())
os.Exit(1)
}
}

Expand Down

0 comments on commit cabcb37

Please sign in to comment.