
yarn add fliphub-resolve
npm i fliphub-resolve --save
- if it's a monorepo package, it will default resolve relative to the monorepo root
- otherwise, it will default resolve relative to the the package root
- the root can be set once, and all other resolving using it will default to that root
- the root can be set for multiple scopes
const resolve = require('fliphub-resolve')
resolve('./path-from-root')
const localResolver = resolve.scoped('local', __dirname)
const monoResolver = resolve.scoped('mono')
const appResolver = resolve.scoped('app').setRoot(1)
- a
number can be passed for shorthand depth
const obj = {
fixtures: './fixtures',
simple: './fixtures/somePath',
simplejs: './fixtures/somePath.js',
}
const resolvedObj = resolve.obj(obj)
- resolves objects, arrays, with multiple scopes.
const arr = ['./fixtures', './fixtures/somePath']
const resolvedArr = resolver.arr(arr)
const arr = ['./fixtures', './fixtures/somePath']
const obj = {
fixtures: './fixtures',
simple: './fixtures/somePath',
simplejs: './fixtures/somePath.js',
}
const resolvedArr = resolver(arr)
const resolvedObj = resolve(obj)
const apps = resolve.scope('app')('./eh.js')
const monos = resolve.scope('mono')('./eh.js')
const locals = resolve.scope('app')(arr)