Skip to content

Commit

Permalink
Add load event
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jul 30, 2019
1 parent ff42285 commit d1b3bbd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { sendParentMessage, getParentMessage } from './ipc_helpers.js'
const run = async function() {
await sendParentMessage('ready')

const parameter = undefined
const { taskPath, parameter } = await getParentMessage('load')

const [mainA, beforeA, afterA] = bindParameter(PARAMETERS, parameter, [
main,
before,
Expand Down
2 changes: 2 additions & 0 deletions src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const startChild = async function() {

await getChildMessage(childProcess, 'ready')

await sendChildMessage(childProcess, 'load', { parameter: undefined })

return childProcess
}

Expand Down
19 changes: 9 additions & 10 deletions src/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ export const getTasks = async function({ tasks, file, cwd }) {
return tasks
}

const taskFile = await getTaskFile(file, cwd)
const taskPath = await getTaskFile(file, cwd)

if (taskFile === undefined) {
if (taskPath === undefined) {
throw new TypeError('No tasks file found')
}

const tasksA = loadTaskFile(taskFile, cwd)

const tasksB = normalizeTasks(tasksA)
return tasksB
const tasksA = loadTaskFile(taskPath)
return tasksA
}

const getTaskFile = async function(file, cwd) {
Expand All @@ -25,7 +23,8 @@ const getTaskFile = async function(file, cwd) {
}

const taskFile = await locatePath(DEFAULT_TASK_PATHS, { cwd })
return taskFile
const taskPath = resolve(cwd, taskFile)
return taskPath
}

const DEFAULT_TASK_PATHS = [
Expand All @@ -37,12 +36,12 @@ const DEFAULT_TASK_PATHS = [
'benchmarks/main.ts',
]

const loadTaskFile = function(taskFile, cwd) {
const taskPath = resolve(cwd, taskFile)
const loadTaskFile = function(taskPath) {
// TODO: replace with `import()` once it is supported by default by ESLint
// eslint-disable-next-line global-require, import/no-dynamic-require
const tasks = require(taskPath)
return tasks
const tasksA = normalizeTasks(tasks)
return tasksA
}

const normalizeTasks = function(tasks) {
Expand Down

0 comments on commit d1b3bbd

Please sign in to comment.