Skip to content

Commit

Permalink
chore(gatsby): Convert utils/tracer/index to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
kawamataryo committed Mar 16, 2020
1 parent 2ff2ba3 commit 0d44cf0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { buildProductionBundle } from "./build-javascript"
const bootstrap = require(`../bootstrap`)
const apiRunnerNode = require(`../utils/api-runner-node`)
const { copyStaticDirs } = require(`../utils/get-static-dir`)
const { initTracer, stopTracer } = require(`../utils/tracer`)
import { initTracer, stopTracer } from "../utils/tracer"
const db = require(`../db`)
const signalExit = require(`signal-exit`)
const telemetry = require(`gatsby-telemetry`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { slash } = require(`gatsby-core-utils`)
const path = require(`path`)
const opentracing = require(`opentracing`)
import { slash } from "gatsby-core-utils"
import path from "path"
import opentracing, { Tracer } from "opentracing"

let tracerProvider

Expand All @@ -13,8 +13,8 @@ let tracerProvider
* `stop` - Run any tracer cleanup required before the node.js process
* exits
*/
function initTracer(tracerFile) {
let tracer
export const initTracer = (tracerFile: string): Tracer => {
let tracer: Tracer
if (tracerFile) {
const resolvedPath = slash(path.resolve(tracerFile))
tracerProvider = require(resolvedPath)
Expand All @@ -28,13 +28,8 @@ function initTracer(tracerFile) {
return tracer
}

async function stopTracer() {
export const stopTracer = async (): Promise<void> => {
if (tracerProvider && tracerProvider.stop) {
await tracerProvider.stop()
}
}

module.exports = {
initTracer,
stopTracer,
}

0 comments on commit 0d44cf0

Please sign in to comment.