Skip to content

Commit 0739c85

Browse files
Gerry Agbobadagagbo
authored andcommitted
Adapt to am_list 0.3
Fixes #103
1 parent a7a1f56 commit 0739c85

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

dist/index.js

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/am_list.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import * as semver from 'semver'
1313
// Removing false positive
1414
// eslint-disable-next-line import/no-unresolved
1515
import {components} from '@octokit/openapi-types'
16-
import {difference} from './utils'
1716

1817
const execAsync = promisify(exec)
1918

@@ -29,6 +28,27 @@ export type AmFunction = {
2928
function: string
3029
}
3130

31+
export type AmLocation = {
32+
file: string
33+
range: AmRange
34+
}
35+
36+
export type AmRange = {
37+
start: AmPosition
38+
end: AmPosition
39+
}
40+
41+
export type AmPosition = {
42+
line: number
43+
column: number
44+
}
45+
46+
export type AmListOutputFunction = {
47+
id: AmFunction
48+
definition?: AmLocation
49+
instrumentation?: AmLocation
50+
}
51+
3252
export type DataSet = {
3353
autometricizedFunctions: AmFunction[]
3454
otherFunctions: AmFunction[]
@@ -136,18 +156,20 @@ export async function computeDataSet(
136156
`${amList} list -a -l ${language} ${projectRoot}`
137157
)
138158

139-
const allFunctions: AmFunction[] = JSON.parse(allFns)
140-
141-
const {stdout: amFns} = await execAsync(
142-
`${amList} list -l ${language} ${projectRoot}`
143-
)
144-
145-
const amFunctions: AmFunction[] = JSON.parse(amFns)
159+
const outputFunctions: AmListOutputFunction[] = JSON.parse(allFns)
160+
const autometricizedFunctions = []
161+
const otherFunctions = []
146162

147-
const otherFunctions = difference(allFunctions, amFunctions)
163+
for (const fn of outputFunctions) {
164+
if (fn.instrumentation) {
165+
otherFunctions.push({...fn.id})
166+
} else {
167+
autometricizedFunctions.push({...fn.id})
168+
}
169+
}
148170

149171
return {
150-
autometricizedFunctions: amFunctions,
172+
autometricizedFunctions,
151173
otherFunctions
152174
}
153175
}

0 commit comments

Comments
 (0)