Skip to content

Commit

Permalink
Merge pull request #105 from algorandfoundation/fix/out-dir-path
Browse files Browse the repository at this point in the history
fix: allow input path in compiler options to be prefixed with ./
  • Loading branch information
boblat authored Feb 7, 2025
2 parents c09f427 + b5486c0 commit 453ee53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/compile-options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
6 changes: 5 additions & 1 deletion src/compile-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 453ee53

Please sign in to comment.