MAESTRO: audit shared templateVariables - fix cross-platform path handling

- Fix PROJECT_NAME to handle both Unix and Windows paths using split(/[/\\]/)
- Fix trailing slash handling with .filter(Boolean)
- Update misleading "deprecated" comment to "aliases" since PROJECT_NAME is actively used in wizard prompts
- Update tests to verify the improved behavior
This commit is contained in:
Pedram Amini
2025-12-21 09:48:41 -06:00
parent c9b6d53c29
commit 2a203b36a9
2 changed files with 6 additions and 7 deletions

View File

@@ -655,8 +655,8 @@ describe('substituteTemplateVariables', () => {
}),
});
const result = substituteTemplateVariables('Name: {{PROJECT_NAME}}', context);
// split('/').pop() on '/path/to/project/' gives ''
expect(result).toBe('Name: ');
// split(/[/\\]/).filter(Boolean).pop() correctly handles trailing slashes
expect(result).toBe('Name: project');
});
it('should handle Windows-style paths', () => {
@@ -666,10 +666,9 @@ describe('substituteTemplateVariables', () => {
cwd: 'C:\\Users\\dev\\project',
}),
});
// Windows paths don't split on '/', so PROJECT_NAME would be the full path
// Windows paths now split on both / and \ to extract the last segment
const result = substituteTemplateVariables('{{PROJECT_NAME}}', context);
// Since split('/') doesn't work on backslashes, it returns the full path
expect(result).toBe('C:\\Users\\dev\\project');
expect(result).toBe('project');
});
it('should handle very long templates efficiently', () => {