Skip to content

Commit

Permalink
Move to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
akameco committed Nov 2, 2017
1 parent 28d7b12 commit d37a888
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 1 addition & 13 deletions src/handlers/plugins.js
Expand Up @@ -4,7 +4,7 @@ import KeyLocker from 'key-locker'
import { compile, getOutputPath, writeFileSync, toErrorStack } from '../utils'
import type { Path, AfterHook, Plugin, EventType } from '../types'
import runHooks from '../hooks/run'
import { log, relativeFromCwd } from '../utils'
import { log, relativeFromCwd, resolveInputPath } from '../utils'
import { formatText } from '../reporters/'

const lock = new KeyLocker()
Expand All @@ -25,18 +25,6 @@ export function compileWithPlugin(eventPath: Path, plugin: Plugin) {
return code ? code.trim() : ''
}

function resolveInputPath(input: ?string, eventPath: Path): Path {
if (!input) {
return eventPath
}

if (path.isAbsolute(input)) {
return input
}

return path.resolve(path.dirname(eventPath), input)
}

export function handlePlugin(
eventPath: Path,
eventType: EventType,
Expand Down
12 changes: 12 additions & 0 deletions src/utils/index.js
Expand Up @@ -67,3 +67,15 @@ export function isAlreadyExist(input: Path) {
return false
}
}

export function resolveInputPath(input: ?string, eventPath: Path): Path {
if (!input) {
return eventPath
}

if (path.isAbsolute(input)) {
return input
}

return path.resolve(path.dirname(eventPath), input)
}

0 comments on commit d37a888

Please sign in to comment.