File tree Expand file tree Collapse file tree 5 files changed +46
-34
lines changed
Sources/SymbolGraphBuilder Expand file tree Collapse file tree 5 files changed +46
-34
lines changed Original file line number Diff line number Diff line change @@ -119,31 +119,18 @@ extension SSGC.PackageBuild
119
119
as type: SSGC . ProjectType = . package ,
120
120
flags: Flags = . init( ) ) -> Self
121
121
{
122
+ /// The projects path could be absolute or relative. If it’s relative, we need to
123
+ /// convert it to an absolute path.
124
+ let projects : FilePath . Directory = projects. absolute ( )
122
125
let project : FilePath . Directory = projects / " \( projectName) "
123
126
let scratch : SSGC . PackageBuildDirectory = . init( configuration: . debug,
124
127
location: project / scratchName)
125
128
126
- if project. path. isAbsolute
127
- {
128
- return . init( id: . unversioned( projectName) ,
129
- scratch: scratch,
130
- flags: flags,
131
- root: project,
132
- type: type)
133
- }
134
- else if
135
- let current: FilePath . Directory = . current( )
136
- {
137
- return . init( id: . unversioned( projectName) ,
138
- scratch: scratch,
139
- flags: flags,
140
- root: . init( path: current. path. appending ( project. path. components) ) ,
141
- type: type)
142
- }
143
- else
144
- {
145
- fatalError ( " Couldn’t determine the current working directory. " )
146
- }
129
+ return . init( id: . unversioned( projectName) ,
130
+ scratch: scratch,
131
+ flags: flags,
132
+ root: project,
133
+ type: type)
147
134
}
148
135
149
136
/// Clones or pulls the specified package from a git repository, checking out
Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ extension SSGC
10
10
11
11
init ( configuration: PackageBuildConfiguration , location: FilePath . Directory )
12
12
{
13
+ guard location. path. isAbsolute
14
+ else
15
+ {
16
+ fatalError ( """
17
+ Package build directory must be an absolute path,
18
+ for IndexStoreDB compatibility!
19
+ """ )
20
+ }
21
+
13
22
self . configuration = configuration
14
23
self . location = location
15
24
}
Original file line number Diff line number Diff line change @@ -31,19 +31,7 @@ extension SSGC.Workspace
31
31
private
32
32
init ( location: FilePath . Directory )
33
33
{
34
- if location. path. isAbsolute
35
- {
36
- self . init ( absolute: location)
37
- }
38
- else if
39
- let current: FilePath . Directory = . current( )
40
- {
41
- self . init ( absolute: . init( path: current. path. appending ( location. path. components) ) )
42
- }
43
- else
44
- {
45
- fatalError ( " Couldn’t determine the current working directory. " )
46
- }
34
+ self . init ( absolute: location. absolute ( ) )
47
35
}
48
36
49
37
public static
Original file line number Diff line number Diff line change
1
+ import System
2
+
3
+ extension FilePath
4
+ {
5
+ func absolute( ) -> Self
6
+ {
7
+ if self . isAbsolute
8
+ {
9
+ return self
10
+ }
11
+ else if
12
+ let current: FilePath . Directory = . current( )
13
+ {
14
+ return current. path. appending ( self . components)
15
+ }
16
+ else
17
+ {
18
+ fatalError ( " Couldn’t determine the current working directory! " )
19
+ }
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ import System
2
+
3
+ extension FilePath . Directory
4
+ {
5
+ func absolute( ) -> Self { . init( path: self . path. absolute ( ) ) }
6
+ }
7
+
You can’t perform that action at this time.
0 commit comments