Skip to content

Commit

Permalink
type and import the importer
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss committed Sep 16, 2021
1 parent 6714025 commit 8037766
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ import HttpStream from '../formatter/http_stream'
import { promisify } from 'util'
import { Writable } from 'stream'
import { pathToFileURL } from 'url'
import importer from '../importer'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../importer')
const { incrementing, uuid } = IdGenerator

export interface ICliRunResult {
Expand Down
3 changes: 1 addition & 2 deletions src/formatter/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import { IParsedArgvFormatOptions } from '../cli/argv_parser'
import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'
import HtmlFormatter from './html_formatter'
import { pathToFileURL } from 'url'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../importer')
import importer from '../importer'

interface IGetStepDefinitionSnippetBuilderOptions {
cwd: string
Expand Down
12 changes: 8 additions & 4 deletions src/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ without having it transpiled down to commonjs `require()` by TypeScript.
See https://github.com/microsoft/TypeScript/issues/43329.
*/

module.exports = {
importer: async (descriptor) => {
return await import(descriptor)
},
/**
* @param {any} descriptor - A URL or path for the module to load
* @return {Promise<any>} Promise that resolves to the loaded module
*/
async function importer(descriptor) {
return await import(descriptor)
}

module.exports = importer
3 changes: 1 addition & 2 deletions src/runtime/parallel/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import { IRuntimeOptions } from '../index'
import { PredictableTestRunStopwatch, RealTestRunStopwatch } from '../stopwatch'
import { duration } from 'durations'
import { pathToFileURL } from 'url'
import importer from '../../importer'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../../importer')
const { uuid } = IdGenerator

type IExitFunction = (exitCode: number, error?: Error, message?: string) => void
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
"lib": ["es2019"],
"module": "commonjs",
Expand Down

0 comments on commit 8037766

Please sign in to comment.