@@ -128,13 +128,6 @@ struct ZipBuilderTool: ParsableCommand {
128
128
129
129
// MARK: - Filesystem Paths
130
130
131
- /// The path to the root of the firebase-ios-sdk repo.
132
- @Option ( help: ArgumentHelp ( """
133
- The path to the repo from which the Firebase distribution is being built.
134
- """ ) ,
135
- transform: URL . init ( fileURLWithPath: ) )
136
- var repoDir : URL
137
-
138
131
/// Path to override podspec search with local podspec.
139
132
@Option ( help: ArgumentHelp ( " Path to override podspec search with local podspec. " ) ,
140
133
transform: URL . init ( fileURLWithPath: ) )
@@ -160,17 +153,6 @@ struct ZipBuilderTool: ParsableCommand {
160
153
// MARK: - Validation
161
154
162
155
mutating func validate( ) throws {
163
- // Validate the repoDir exists, as well as the templateDir.
164
- guard FileManager . default. directoryExists ( at: repoDir) else {
165
- throw ValidationError ( " Included a repo-dir that doesn't exist. " )
166
- }
167
-
168
- // Validate the templateDir exists.
169
- let templateDir = ZipBuilder . FilesystemPaths. templateDir ( fromRepoDir: repoDir)
170
- guard FileManager . default. directoryExists ( at: templateDir) else {
171
- throw ValidationError ( " Missing template inside of the repo. \( templateDir) does not exist. " )
172
- }
173
-
174
156
// Validate the output directory if provided.
175
157
if let outputDir = outputDir, !FileManager. default. directoryExists ( at: outputDir) {
176
158
throw ValidationError ( " `output-dir` passed in does not exist. Value: \( outputDir) " )
@@ -216,6 +198,22 @@ struct ZipBuilderTool: ParsableCommand {
216
198
FileManager . registerBuildRoot ( buildRoot: buildRoot. standardizedFileURL)
217
199
}
218
200
201
+ // Get the repoDir by deleting four path components from this file to the repo root.
202
+ let repoDir = URL ( fileURLWithPath: #file)
203
+ . deletingLastPathComponent ( ) . deletingLastPathComponent ( )
204
+ . deletingLastPathComponent ( ) . deletingLastPathComponent ( )
205
+
206
+ // Validate the repoDir exists, as well as the templateDir.
207
+ guard FileManager . default. directoryExists ( at: repoDir) else {
208
+ fatalError ( " Failed to find the repo root at \( repoDir) . " )
209
+ }
210
+
211
+ // Validate the templateDir exists.
212
+ let templateDir = ZipBuilder . FilesystemPaths. templateDir ( fromRepoDir: repoDir)
213
+ guard FileManager . default. directoryExists ( at: templateDir) else {
214
+ fatalError ( " Missing template inside of the repo. \( templateDir) does not exist. " )
215
+ }
216
+
219
217
let paths = ZipBuilder . FilesystemPaths ( repoDir: repoDir,
220
218
buildRoot: buildRoot,
221
219
outputDir: outputDir,
0 commit comments