Skip to content

Commit

Permalink
BREAKING CHANGE: outside of root moved to aliasDangrous #3
Browse files Browse the repository at this point in the history
  • Loading branch information
oklas committed Feb 10, 2021
1 parent 93cfc0d commit 0ee4707
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,25 @@ function expandPluginsScope(plugins, dirs, files) {
}
}

function checkOutside(aliasMap) {
const outside = Object.keys(aliasMap).reduce( (a, i) => {
const rel = path.relative(paths.appPath, aliasMap[i])
const outside = rel.startsWith('..') || path.isAbsolute(rel)
if(outside) console.error(
`alias '${i}' is outside of root - supported only by aliasDangerous`
)
return a || outside
}, false)
if(outside) {
console.error(
`https://github.com/oklas/react-app-rewire-alias#outside-of-root`
)
process.exit(-1)
}
}

function alias(aliasMap) {
checkOutside(aliasMap)
const aliasLocal = Object.keys(aliasMap).reduce( (a,i) => {
a[i] = path.resolve(paths.appPath, aliasMap[i])
return a
Expand Down

0 comments on commit 0ee4707

Please sign in to comment.