Skip to content

Commit

Permalink
add correct version of resolve_relative
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Nov 9, 2024
1 parent 88d0f9c commit 1e20958
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/staxfile/evaluator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { dasherize, dig, resolve } from '~/utils'
import { EvaluationContext, ExpressionWarning } from '~/yamler'
import { symbolRegex } from '~/yamler/symbolizer'
import { dirname } from 'path'
import icons from '~/icons'
import Staxfile from '.'
import inquirer from 'inquirer'
Expand Down Expand Up @@ -44,6 +45,7 @@ export default class Evaluator {
if (name === 'mount_workspace') return this.mountWorkspace()
if (name === 'mount_ssh_auth_sock') return this.mountSshAuthSock()
if (name === 'resolve') return resolve(context.baseDir, args[0])
if (name === 'resolve_relative') return resolve(dirname(context.symbol.file), args[0])
if (name === 'user') return process.env.USER || ''
if (name === 'user_id') return process.getuid()
if (name === 'dasherize') return dasherize(args[0])
Expand Down
2 changes: 1 addition & 1 deletion src/yamler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface EvaluationContext {
baseDir: string
attributes: Record<string, any>
path: string
symbol: object
symbol: Record<string, any>
name: string
args: string[]
}
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/imports/base.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
!import sub/sub.yaml as sub

stax:
stax: !extends sub
app: base_app
vars:
ruby_version: 1.0.0
2 changes: 2 additions & 0 deletions tests/fixtures/imports/sub/sub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
with_resolve_relative: ${{ resolve_relative . }}
with_resolve: ${{ resolve . }}
2 changes: 2 additions & 0 deletions tests/unit/staxfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ describe('Staxfile', () => {
rails_server_port: 3000
},
requires: [ 'mysql', 'caddy' ],
with_resolve: fixturesDir,
with_resolve_relative: join(fixturesDir, 'imports/sub'),
after_setup: 'echo rails_app /workspaces/rails_app'
})
})
Expand Down

0 comments on commit 1e20958

Please sign in to comment.