Skip to content

Commit

Permalink
Add ability to set shared folder root path
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed Nov 20, 2023
1 parent 8e614d6 commit f6fb8a1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
28 changes: 28 additions & 0 deletions Docs/commands-help/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Project: Example
Git branch: main
RUGBY_KEEP_HASH_YAMLS: NO
RUGBY_PRINT_MISSING_BINARIES: NO
RUGBY_SHARED_PARENT_DIR: /Users/swiftyfinch
```
You can find the same environment output in the head of each Rugby log file.
Expand Down Expand Up @@ -61,3 +62,30 @@ RUGBY_PRINT_MISSING_BINARIES=YES rugby
┗━ Moya-framework (a4a42b2)
┗━ Alamofire-framework (85d4367)
```

### Set a custom path to shared folder root

A path to the root of shared folder (without `.rugby` folder name).
By default:
```objc
RUGBY_SHARED_DIR_ROOT=$HOME rugby
```
```sh
~
└─ .rugby # shared folder
├─ bin
└─ logs
```

You can set a different one. For example, a current directory:
```objc
RUGBY_SHARED_DIR_ROOT=`pwd` rugby
```
```sh
pwd
└─ .rugby # shared folder combined with local one
├─ backup
├─ bin
├─ build
└─ logs
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ final class Environment {
// swiftlint:disable identifier_name
private let RUGBY_KEEP_HASH_YAMLS = "RUGBY_KEEP_HASH_YAMLS"
private let RUGBY_PRINT_MISSING_BINARIES = "RUGBY_PRINT_MISSING_BINARIES"
private let RUGBY_SHARED_DIR_ROOT = "RUGBY_SHARED_DIR_ROOT"
// swiftlint:enable identifier_name
}

extension Environment: IEnvironment {
var all: [String: String] {
[
RUGBY_KEEP_HASH_YAMLS: keepHashYamls.yesNo,
RUGBY_PRINT_MISSING_BINARIES: printMissingBinaries.yesNo
RUGBY_PRINT_MISSING_BINARIES: printMissingBinaries.yesNo,
RUGBY_SHARED_DIR_ROOT: sharedFolderParentPath

Check warning on line 18 in Sources/Rugby/Core/Dependencies/Environment/Environment.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Rugby/Core/Dependencies/Environment/Environment.swift#L17-L18

Added lines #L17 - L18 were not covered by tests
]
}

Expand All @@ -24,6 +26,10 @@ extension Environment: IEnvironment {
var printMissingBinaries: Bool {
ProcessInfo.processInfo.environment[RUGBY_PRINT_MISSING_BINARIES].isEnabled
}

var sharedFolderParentPath: String {
ProcessInfo.processInfo.environment[RUGBY_SHARED_DIR_ROOT] ?? Folder.home.path
}

Check warning on line 32 in Sources/Rugby/Core/Dependencies/Environment/Environment.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Rugby/Core/Dependencies/Environment/Environment.swift#L30-L32

Added lines #L30 - L32 were not covered by tests
}

private extension String? {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Rugby/Rugby.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct Rugby: AsyncParsableCommand {
logger: Logger(clock: Clock()),
router: Router(
workingDirectory: Folder.current,
sharedFolderPath: Folder.home.path
sharedFolderPath: env.sharedFolderParentPath

Check warning on line 79 in Sources/Rugby/Rugby.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Rugby/Rugby.swift#L79

Added line #L79 was not covered by tests
)
)
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/RugbyFoundation/Core/Common/IEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ public protocol IEnvironment: AnyObject {

/// A flag to print missing binaries as a tree during an analysing process.
var printMissingBinaries: Bool { get }

/// A path to the root of shared folder (without `.rugby` folder name).
var sharedFolderParentPath: String { get }
}

0 comments on commit f6fb8a1

Please sign in to comment.