Skip to content

Commit

Permalink
kill process after command finishes - fix #27
Browse files Browse the repository at this point in the history
  • Loading branch information
zvictor committed Jul 15, 2022
1 parent f662ea9 commit 98380cd
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
)

console.log(`The sdk has been saved at ${location}`)
process.exit(0)
})()
}
2 changes: 2 additions & 0 deletions commands/deploy-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
`User-defined function(s) created or updated:`,
refs.map((x) => x.name)
)

process.exit(0)
})()
}
2 changes: 2 additions & 0 deletions commands/deploy-indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
`User-defined index(es) created or updated:`,
refs.map((x) => x.name)
)

process.exit(0)
})()
}
2 changes: 2 additions & 0 deletions commands/deploy-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
`User-defined role(s) created or updated:`,
refs.map((x) => x.name)
)

process.exit(0)
})()
}
1 change: 1 addition & 0 deletions commands/deploy-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
}

console.log(await main(inputPath))
process.exit(0)
})()
}
2 changes: 2 additions & 0 deletions commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
}

await main(types)

console.log(`\n\nAll done! All deployments have been successful 馃`)
process.exit(0)
})()
}
2 changes: 2 additions & 0 deletions commands/pull-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
if (!outputPath) {
console.log(schema)
}

process.exit(0)
})()
}
2 changes: 2 additions & 0 deletions commands/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
}

await main(types)

console.log(`All reset operations have succeeded.`)
process.exit(0)
})()
}
4 changes: 3 additions & 1 deletion tests/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export const setupEnvironment = (name, options = {}) => {
end(() => {
deleteDatabase(dbName, process.env.TESTS_SECRET)
delete process.env.BRAINYDUCK_CACHE
debug(`Deleted database ${timestamp}_${name}`)
})
debug(`Deleted database ${timestamp}_${name}`)

afterAll(() => faunaClient().close())
}

export const amountOfFunctionsCreated = () => faunaClient().query(q.Count(q.Functions()))
Expand Down
11 changes: 9 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ export const loadSecret = () => {
return secret
}

let _faunaClient

export const faunaClient = () => {
if (_faunaClient) {
return _faunaClient
}

const { FAUNA_DOMAIN, FAUNA_SCHEME, FAUNA_PORT } = process.env
const options = { secret: loadSecret() }
const options = { secret: loadSecret(), http2SessionIdleTime: 100 }

if (FAUNA_DOMAIN) {
options.domain = process.env.FAUNA_DOMAIN
Expand All @@ -97,7 +103,8 @@ export const faunaClient = () => {
options.port = process.env.FAUNA_PORT
}

return new Client(options)
_faunaClient = new Client(options)
return _faunaClient
}

export const patternMatch = async (pattern, cwd = process.cwd()) =>
Expand Down

0 comments on commit 98380cd

Please sign in to comment.