Skip to content

Commit

Permalink
refactor(cli): improve logic for dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardobridge committed May 13, 2024
1 parent 219f245 commit 350cc71
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,7 @@ function createContext(script, contextVars, additionalProperties = {}) {
$environment: script._environment,
$processEnvironment: process.env, // TODO: deprecate
$env: process.env,
$testId: global.artillery.testRunId,
$dirname: path.dirname(script._configPath)
$testId: global.artillery.testRunId
},
contextVars || {}
),
Expand All @@ -466,6 +465,10 @@ function createContext(script, contextVars, additionalProperties = {}) {
...additionalPropertiesWithoutOverride
};

if (script._configPath) {
INITIAL_CONTEXT.vars.$dirname = path.dirname(script._configPath);
}

let result = INITIAL_CONTEXT;

// variables from payloads:
Expand All @@ -477,6 +480,7 @@ function createContext(script, contextVars, additionalProperties = {}) {

result._uid = uuidv4();
result.vars.$uuid = result._uid;

return result;
}

Expand Down

0 comments on commit 350cc71

Please sign in to comment.