Skip to content

Commit e9b4d19

Browse files
pass variables instead of using template literals. template literals are an antipattern in queries
1 parent 3fa439c commit e9b4d19

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

scripts/get_contributors.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ require('dotenv').config()
22
const { Octokit } = require("@octokit/core")
33

44
module.exports = async function (filepath) {
5-
// Translate Windows-style paths to Unix-style paths.
6-
filepath = filepath.replace(/\\/g, "/")
5+
const unixStyleFilepath = filepath.replace(/\\/g, "/")
76
const octokit = new Octokit({
87
auth: process.env.TOKEN
98
})
109
const { repository: { object: { history } } } = await octokit.graphql(
11-
`{
10+
`query ($filepath: String!) {
1211
repository(owner: "InnerSourceCommons", name: "InnerSourceLearningPath") {
1312
object(expression: "main") {
1413
... on Commit {
15-
history(first: 100, path: "${filepath}") {
14+
history(first: 100, path: $filepath) {
1615
totalCount
1716
nodes {
1817
authors(first: 100) {
@@ -44,7 +43,9 @@ module.exports = async function (filepath) {
4443
}
4544
}
4645
}
47-
}`
46+
}`, {
47+
filepath: unixStyleFilepath
48+
}
4849
)
4950

5051
if (history.totalCount > 100) {

0 commit comments

Comments
 (0)