Skip to content

Commit

Permalink
feat!: move mocha options to task options
Browse files Browse the repository at this point in the history
  • Loading branch information
apaleslimghost authored and ivomurrell committed Sep 4, 2024
1 parent 686f84c commit 073d737
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 0 additions & 2 deletions lib/schemas/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DopplerSchema } from './plugins/doppler'
import { RootSchema } from './plugins/dotcom-tool-kit'
import { HerokuSchema } from './plugins/heroku'
import { LintStagedNpmSchema } from './plugins/lint-staged-npm'
import { MochaSchema } from './plugins/mocha'
import { SmokeTestSchema } from './plugins/n-test'
import { NextRouterSchema } from './plugins/next-router'
import { NodeSchema } from './plugins/node'
Expand All @@ -25,7 +24,6 @@ export const PluginSchemas = {
'@dotcom-tool-kit/doppler': DopplerSchema,
'@dotcom-tool-kit/heroku': HerokuSchema,
'@dotcom-tool-kit/lint-staged-npm': LintStagedNpmSchema,
'@dotcom-tool-kit/mocha': MochaSchema,
'@dotcom-tool-kit/n-test': SmokeTestSchema,
'@dotcom-tool-kit/next-router': NextRouterSchema,
'@dotcom-tool-kit/node': NodeSchema,
Expand Down
4 changes: 3 additions & 1 deletion lib/schemas/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { type InferSchemaOptions } from './infer'
import { BabelSchema } from './tasks/babel'
import { ESLintSchema } from './tasks/eslint'
import { JestSchema } from './tasks/jest'
import { MochaSchema } from './tasks/mocha'

export const TaskSchemas = {
Babel: BabelSchema,
Eslint: ESLintSchema,
Jest: JestSchema
Jest: JestSchema,
Mocha: MochaSchema
}

export type TaskOptions = InferSchemaOptions<typeof TaskSchemas>
File renamed without changes.
10 changes: 5 additions & 5 deletions plugins/mocha/src/tasks/mocha.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { hookFork, waitOnExit } from '@dotcom-tool-kit/logger'
import { Task } from '@dotcom-tool-kit/base'
import { glob } from 'glob'
import { MochaSchema } from '@dotcom-tool-kit/schemas/lib/plugins/mocha'
import { MochaSchema } from '@dotcom-tool-kit/schemas/lib/tasks/mocha'
import { fork } from 'child_process'
import { promisify } from 'util'
const mochaCLIPath = require.resolve('mocha/bin/mocha')

export default class Mocha extends Task<{ plugin: typeof MochaSchema }> {
export default class Mocha extends Task<{ task: typeof MochaSchema }> {
static description = ''

async run(): Promise<void> {
const files = await promisify(glob)(this.pluginOptions.files)
const files = await promisify(glob)(this.options.files)

const args = ['--color', ...files]
if (this.pluginOptions.configPath) {
args.unshift(`--config=${this.pluginOptions.configPath}`)
if (this.options.configPath) {
args.unshift(`--config=${this.options.configPath}`)
}
this.logger.info(`running mocha ${args.join(' ')}`)
const child = fork(mochaCLIPath, args, { silent: true })
Expand Down

0 comments on commit 073d737

Please sign in to comment.