Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 25, 2019
1 parent e3b6fb0 commit 8dc2d80
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
17 changes: 5 additions & 12 deletions src/iterations/validate.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
// Validate that identifiers don't use characters that we are using for parsing
// (e.g. , and = are used by `--limit`) or could use in the future.
export const validateIds = function({
taskId,
variationId,
commandId,
systemId,
}) {
validateId(taskId, 'task')
validateId(variationId, 'variation')
validateId(commandId, 'command')
validateId(systemId, 'systemId')
export const validateIds = function(ids) {
Object.entries(ids).forEach(validateId)
}

const validateId = function(id, name) {
const validateId = function([name, id]) {
if (!VALID_ID_REGEXP.test(id)) {
const nameA = name.replace('Id', '')
throw new TypeError(
`Invalid ${name} '${id}': must contain only letters, digits or _ . -`,
`Invalid ${nameA} '${id}': must contain only letters, digits or _ . -`,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/run/description.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { promisify } from 'util'

const pExecFile = promisify(execFile)

// Runtime versions for this runner, specified as `command.versions`
// Runtime description for this runner, specified as `command.versions`
// Used by the `--info` option
export const getCommandDescription = async function({
commandTitle,
Expand Down
8 changes: 4 additions & 4 deletions src/run/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ export const findRunners = function(taskPath, runners) {
return runnersA
}

const matchExtension = function(extensions, extension) {
return extensions.some(extensionA => `.${extensionA}` === extension)
}

// Inverse.
// Only trigger `runner.commands()` if the runner is used by some benchmark
// files.
Expand All @@ -25,3 +21,7 @@ export const hasTasks = function({ extensions }, taskPaths) {
matchExtension(extensions, extname(taskPath)),
)
}

const matchExtension = function(extensions, extension) {
return extensions.some(extensionA => `.${extensionA}` === extension)
}
2 changes: 1 addition & 1 deletion src/run/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const loadRunner = async function({
return { commands: commandsA, extensions }
}

// Fire runner `runner.commands()`
// Fire `runner.commands()`
const fireCommands = async function({ runnerId, runOpt, retrieveCommands }) {
try {
return await retrieveCommands(runOpt)
Expand Down

0 comments on commit 8dc2d80

Please sign in to comment.