diff --git a/src/compile-options.spec.ts b/src/compile-options.spec.ts index b7d3ff8b8..dec3acfc8 100644 --- a/src/compile-options.spec.ts +++ b/src/compile-options.spec.ts @@ -5,6 +5,13 @@ import { determineOutDir } from './compile-options' describe('determineOutDir', () => { const isWindows = os.platform() === 'win32' it.each([ + // Relative input path with explicit ./ + ['./examples/*', 'examples/hello/contract.algo.ts', 'out', 'examples/hello/out'], + ['./examples/*', 'examples/hello/nested/contract.algo.ts', 'out', 'examples/hello/out/nested'], + ['./examples/**', 'examples/hello/nested/contract.algo.ts', 'out', 'examples/hello/nested/out'], + ['./examples', 'examples/hello/contract.algo.ts', 'out', 'examples/out/hello'], + ['./examples/hello', 'examples/hello/contract.algo.ts', 'out', 'examples/hello/out'], + ['./examples/hello/contract.algo.ts', 'examples/hello/contract.algo.ts', 'out', 'examples/hello/out'], // Relative outDir ['examples/*', 'examples/hello/contract.algo.ts', 'out', 'examples/hello/out'], ['examples/*', 'examples/hello/nested/contract.algo.ts', 'out', 'examples/hello/out/nested'], diff --git a/src/compile-options.ts b/src/compile-options.ts index 9b36b417f..ee1aa1fb1 100644 --- a/src/compile-options.ts +++ b/src/compile-options.ts @@ -83,8 +83,12 @@ export const buildCompileOptions = ({ } } +function trimCurrentDir(path: string) { + return path.startsWith('./') ? path.slice(2) : path +} + function findMinimalMatch(inputPath: string, testPath: string): string { - const [matchedPath] = minimatch.match([testPath], inputPath) + const [matchedPath] = minimatch.match([trimCurrentDir(testPath)], trimCurrentDir(inputPath)) if (matchedPath) { if (matchedPath.endsWith('.algo.ts')) { return upath.dirname(matchedPath)