Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber.

## [Unreleased]
### Fixed
- Allows for parentheses in paths for developers working on cucumber's own code ([[#1735](https://github.com/cucumber/cucumber-js/issues/1735)])

## [8.0.0-rc.1] - 2021-10-19
### Added
Expand Down
27 changes: 0 additions & 27 deletions features/custom_stack_trace.feature

This file was deleted.

103 changes: 2 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"node": ">=12"
},
"dependencies": {
"@cspotcode/source-map-support": "^0.7.0",
"@cucumber/create-meta": "6.0.2",
"@cucumber/cucumber-expressions": "^14.0.0",
"@cucumber/gherkin": "^22.0.0",
Expand All @@ -206,7 +207,6 @@
"resolve": "^1.19.0",
"resolve-pkg": "^2.0.0",
"stack-chain": "^2.0.0",
"stacktrace-js": "^2.0.2",
"string-argv": "^0.3.1",
"tmp": "^0.2.1",
"util-arity": "^1.1.0",
Expand Down
30 changes: 15 additions & 15 deletions src/support_code_library_builder/get_definition_line_and_uri.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import path from 'path'
import StackTrace from 'stacktrace-js'
import { wrapCallSite } from '@cspotcode/source-map-support'
import stackChain from 'stack-chain'
import { isFileNameInCucumber } from '../stack_trace_filter'
import { doesHaveValue, valueOrDefault } from '../value_checker'
import { ILineAndUri } from '../types'
import CallSite = NodeJS.CallSite

export function getDefinitionLineAndUri(
cwd: string,
isExcluded = isFileNameInCucumber
): ILineAndUri {
let line: number
let uri: string
try {
const stackframes = StackTrace.getSync()
const stackframe = stackframes.find(
(frame) =>
frame.getFileName() !== __filename && !isExcluded(frame.getFileName())
)
if (stackframe != null) {
line = stackframe.getLineNumber()
uri = stackframe.getFileName()
if (doesHaveValue(uri)) {
uri = path.relative(cwd, uri)
}

const stackframes: CallSite[] = stackChain.callSite().map(wrapCallSite)
const stackframe = stackframes.find(
(frame: CallSite) =>
frame.getFileName() !== __filename && !isExcluded(frame.getFileName())
)
if (stackframe != null) {
line = stackframe.getLineNumber()
uri = stackframe.getFileName()
if (doesHaveValue(uri)) {
uri = path.relative(cwd, uri)
}
} catch (e) {
console.warn('Warning: unable to get definition line and uri', e)
}

return {
line: valueOrDefault(line, 0),
uri: valueOrDefault(uri, 'unknown'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import assert from 'assert'
import { getDefinitionLineAndUri } from './get_definition_line_and_uri'
import path from 'path'

describe(getDefinitionLineAndUri.name, () => {
it('correctly gets the filename of the caller', () => {
const includeAnyFile = (): boolean => false
const { uri, line } = getDefinitionLineAndUri('.', includeAnyFile)
assert.strictEqual(
path.normalize(uri),
path.normalize(
'src/support_code_library_builder/get_definition_line_and_uri_spec.ts'
)
)
assert.strictEqual(line, 8)
})
})