atom/fs-plus

resolve - loadPaths argument is not properly handled

Faleij opened this issue · 0 comments

fs-plus.coffee

# loadPaths - An {Array} of absolute and relative paths to search.

...

resolve: (args...) ->
    extensions = args.pop() if _.isArray(_.last(args))
    pathToResolve = args.pop()?.toString()
    loadPaths = args

when loadPaths is assigned args, args is an array containing the rest of the parameters - excluding extensions and pathToResolve. args will unexpectedly be a nested array (it should not be) and the resolve method will break because of this. As I have seen implementations using a single string as argument, I propose that loadPaths should be able to be a string or an array;

loadPaths = if _.isArray(_.last(args)) args.pop() else args 

example showing when it breaks: https://runkit.com/58679334ff226c001410a427/586793351fc1d20015993407