Skip to content

Commit ad4a164

Browse files
committed
api: hook in new resolver api for resolving paths
1 parent 6454939 commit ad4a164

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

api.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ type Options struct {
2626
Reporter Reporter
2727

2828
Transforms transforms.Options
29+
30+
// Resolver is a path resolver. If not specified, the default node-style
31+
// resolver will be used.
32+
Resolver Resolver
2933
}
3034

3135
func newCompilation(opts Options) *compilation {
@@ -38,12 +42,17 @@ func newCompilation(opts Options) *compilation {
3842
result: newResult(),
3943
reporter: logging.DefaultReporter,
4044
transforms: opts.Transforms,
45+
resolver: &NodeResolver{},
4146
}
4247

4348
if opts.Reporter != nil {
4449
c.reporter = opts.Reporter
4550
}
4651

52+
if opts.Resolver != nil {
53+
c.resolver = opts.Resolver
54+
}
55+
4756
return c
4857
}
4958

@@ -169,7 +178,12 @@ func (c *compilation) parseFile(file string, hasOutput bool) *ast.Stylesheet {
169178
var wg errgroup.Group
170179
for _, imp := range ss.Imports {
171180
wg.Go(func() error {
172-
rel := filepath.Join(filepath.Dir(source.Path), imp.Value)
181+
rel, err := c.resolver.Resolve(imp.Value, filepath.Dir(source.Path))
182+
if err != nil {
183+
c.addError(err)
184+
return nil
185+
}
186+
173187
// If import follow is on, then every referenced file makes it to the output.
174188
imported := c.parseFile(rel, c.transforms.ImportRules == transforms.ImportRulesFollow)
175189

0 commit comments

Comments
 (0)