aws / aws/aws-cdk

aws-cdk: Replace `__dirname`

Open
#26,054 1 comment 0 reactions 0 assignees View on GitHub
effort/medium feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the feature

Replace the global variable `__dirname` used with an alternative that properly handles special characters and is more widely supported

### Use Case

I've seen issues in #21161, and #18470, and may be running into issues myself due to path resolution shenanigans on my system with the `__dirname` global variable.

### Proposed Solution

It seems feasible from my limited knowledge of Node.js to use `path.dirname(url.fileURLToPath(import.meta.url))` instead, given its introduction back in Node.js 10.12.

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.80.0

### Environment details (OS name and version, etc.)

NixOS 23.05

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by locating the repository's uses of __dirname and reviewing the Node.js path-resolution context around them. Done means the relevant uses no longer rely on __dirname, handle special characters correctly, and the existing tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.