mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 08:17:34 -04:00
19 lines
545 B
JavaScript
19 lines
545 B
JavaScript
|
/* @flow */
|
||
|
"use strict"
|
||
|
|
||
|
const configurationError = require("./configurationError")
|
||
|
const resolveFrom = require("resolve-from")
|
||
|
|
||
|
module.exports = function (basedir/*: string*/, lookup/*: string*/)/*: string*/ {
|
||
|
// First try to resolve from the provided directory,
|
||
|
// then try to resolve from process.cwd.
|
||
|
let path = resolveFrom(basedir, lookup)
|
||
|
if (!path) {
|
||
|
path = resolveFrom(process.cwd(), lookup)
|
||
|
}
|
||
|
if (!path) {
|
||
|
throw configurationError(`Could not find "${lookup}". Do you need a \`configBasedir\`?`)
|
||
|
}
|
||
|
return path
|
||
|
}
|