Skip to content

Commit 4c58f23

Browse files
committed
Cleanup imports
Disambiguate `__dirname`, which is still not quite right.
1 parent 5b73175 commit 4c58f23

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

Sources/connect/Connect.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Noze.io / Macro
44
//
55
// Created by Helge Heß on 5/3/16.
6-
// Copyright © 2016-2020 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2016-2025 ZeeZide GmbH. All rights reserved.
77
//
88

99
import class http.Server
@@ -194,6 +194,7 @@ public extension Connect {
194194
}
195195

196196
import func MacroCore.__dirname
197+
// TBD: can we make those internal? They produce ambiguities.
197198

198199
#if swift(>=5.3)
199200
@inlinable

Sources/express/View.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
// View.swift
33
// MacroExpress
44
//
5-
// Created by Helge Heß on 07.09.25.
5+
// Created by Helge Heß on 09/07/25.
6+
// Copyright © 2025 ZeeZide GmbH. All rights reserved.
67
//
78

8-
import Macro
9+
import MacroCore
10+
import fs
911

1012
public extension SettingsHolder {
1113

@@ -22,11 +24,10 @@ public extension SettingsHolder {
2224
/**
2325
* The views directory for templates set by `app.set("views", "views")`.
2426
*/
25-
@inlinable
2627
var views : [ String ] {
2728
switch settings["views"] {
2829
case .none:
29-
return [ process.env["EXPRESS_VIEWS"] ?? __dirname() + "/views" ]
30+
return [ process.env["EXPRESS_VIEWS"] ?? __dirname() + "/views" ]
3031
case let v as String: return [ v ]
3132
case let v as [ String ]: return v
3233
case .some(let v):
@@ -59,7 +60,7 @@ extension Express {
5960

6061
/// The render function for the extension specified in ``ext`` (i.e. passed
6162
/// explicitly to the render function, like `render("index.mustache")`.
62-
public let engine : ExpressEngine?
63+
public var engine : ExpressEngine?
6364

6465
/// All known engines
6566
private let engines : [ String : ExpressEngine ]
@@ -69,7 +70,7 @@ extension Express {
6970

7071
public required init(name: String, options: Express) {
7172
self.name = name
72-
self.ext = Macro.path.extname(name)
73+
self.ext = fs.path.extname(name)
7374
self.engines = options.engines
7475
self.root = options.views
7576
self.defaultEngine = options.defaultEngine

Sources/express/dirname.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// dirname.swift
3+
// MacroExpress
4+
//
5+
// Created by Helge Heß on 09/07/25.
6+
// Copyright © 2025 ZeeZide GmbH. All rights reserved.
7+
//
8+
9+
// Disambiguate __dirname (connect vs MacroCore, maybe connect should be
10+
// internal?)
11+
12+
import func MacroCore.__dirname
13+
14+
#if swift(>=5.3)
15+
func __dirname(caller: String = #filePath) -> String {
16+
return MacroCore.__dirname(caller: caller)
17+
}
18+
#else
19+
func __dirname(caller: String = #file) -> String {
20+
return MacroCore.__dirname(caller: caller)
21+
}
22+
#endif

0 commit comments

Comments
 (0)