Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize paths when looking up items on outputCache #1038

Merged
merged 2 commits into from May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/index.spec.ts
Expand Up @@ -189,7 +189,7 @@ describe('ts-node', function () {
}

expect(err.message).to.contain([
`${join(__dirname, '../tests/throw.ts')}:3`,
`${join(__dirname, '../tests/throw.ts')}:100`,
' bar () { throw new Error(\'this is a demo\') }',
' ^',
'Error: this is a demo'
Expand All @@ -206,7 +206,7 @@ describe('ts-node', function () {
}

expect(err.message).to.contain([
`${join(__dirname, '../tests/throw.ts')}:3`,
`${join(__dirname, '../tests/throw.ts')}:100`,
' bar () { throw new Error(\'this is a demo\') }',
' ^'
].join('\n'))
Expand Down Expand Up @@ -611,7 +611,7 @@ describe('ts-node', function () {
} catch (error) {
expect(error.stack).to.contain([
'Error: this is a demo',
` at Foo.bar (${join(__dirname, '../tests/throw.ts')}:3:18)`
` at Foo.bar (${join(__dirname, '../tests/throw.ts')}:100:18)`
].join('\n'))

done()
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -420,7 +420,7 @@ export function create (rawOptions: CreateOptions = {}): Register {
sourceMapSupport.install({
environment: 'node',
retrieveFile (path: string) {
return outputCache.get(path)?.content || ''
return outputCache.get(normalizeSlashes(path))?.content || ''
}
})

Expand Down
97 changes: 97 additions & 0 deletions tests/throw.ts
@@ -1,4 +1,101 @@
// intentional whitespace to prove that sourcemaps are working. Throw should happen on line 100.
// 100 lines is meant to be far more space than the helper functions would take.
class Foo {































































































constructor () { this.bar() }
bar () { throw new Error('this is a demo') }
}
Expand Down