Skip to content

Instantly share code, notes, and snippets.

@jchaffin
Created June 20, 2017 12:40
Show Gist options
  • Save jchaffin/ed7cc9d60ef8028c8989b136bfc47910 to your computer and use it in GitHub Desktop.
Save jchaffin/ed7cc9d60ef8028c8989b136bfc47910 to your computer and use it in GitHub Desktop.
Splitting a relative path
function splitPath(...relPath) {
return relPath.reduce(
(a, b) => (/\.?\//).test(b) ? a.concat(b) : a.concat('/', b),
rootDir
)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment