@@ -63,10 +63,9 @@ function createCompileOptions({
6363 }
6464}
6565
66- async function ensureSourceDetectionRootExists (
67- compiler : { root : Awaited < ReturnType < typeof compile > > [ 'root' ] } ,
68- base : string ,
69- ) {
66+ async function ensureSourceDetectionRootExists ( compiler : {
67+ root : Awaited < ReturnType < typeof compile > > [ 'root' ]
68+ } ) {
7069 // Verify if the `source(…)` path exists (until the glob pattern starts)
7170 if ( compiler . root && compiler . root !== 'none' ) {
7271 let globSymbols = / [ * { ] /
@@ -80,25 +79,27 @@ async function ensureSourceDetectionRootExists(
8079 }
8180
8281 let exists = await fsPromises
83- . stat ( path . resolve ( base , basePath . join ( '/' ) ) )
82+ . stat ( path . resolve ( compiler . root . base , basePath . join ( '/' ) ) )
8483 . then ( ( stat ) => stat . isDirectory ( ) )
8584 . catch ( ( ) => false )
8685
8786 if ( ! exists ) {
88- throw new Error ( `The \`source(${ compiler . root . pattern } )\` does not exist` )
87+ throw new Error (
88+ `The \`source(${ compiler . root . pattern } )\` does not exist or is not a directory.` ,
89+ )
8990 }
9091 }
9192}
9293
9394export async function compileAst ( ast : AstNode [ ] , options : CompileOptions ) {
9495 let compiler = await _compileAst ( ast , createCompileOptions ( options ) )
95- await ensureSourceDetectionRootExists ( compiler , options . base )
96+ await ensureSourceDetectionRootExists ( compiler )
9697 return compiler
9798}
9899
99100export async function compile ( css : string , options : CompileOptions ) {
100101 let compiler = await _compile ( css , createCompileOptions ( options ) )
101- await ensureSourceDetectionRootExists ( compiler , options . base )
102+ await ensureSourceDetectionRootExists ( compiler )
102103 return compiler
103104}
104105
0 commit comments