Browse files

Fix babel only regexp on windows

cli / packager was broken on Windows after 28f1c67.

Babel `only` regexp option requires paths to use forward slashes only but `__dirname` will use backslashes on windows. This simply adds a replace to normalize to forward slashes.

cc jeanlauliac cpojer
Closes #11850

Reviewed By: cpojer

Differential Revision: D4409143

Pulled By: jeanlauliac

fbshipit-source-id: a705236630959f762e53100299ab073ec9a29ee1
  • Loading branch information...
janicduplessis authored and facebook-github-bot committed Jan 12, 2017
1 parent c68a708 commit 6b1bc4ad74310558b86d57186ce28eebf705a7a8
Showing with 3 additions and 1 deletion.
  1. +3 −1 setupBabel.js
@@ -26,7 +26,9 @@ const BABEL_ENABLED_PATHS = [
function buildRegExps(basePath, dirPaths) {
return =>
new RegExp(`^${escapeRegExp(path.resolve(basePath, folderPath))}`)
// Babel `only` option works with forward slashes in the RegExp so replace
// backslashes for Windows.
new RegExp(`^${escapeRegExp(path.resolve(basePath, folderPath).replace(/\\/g, '/'))}`)

0 comments on commit 6b1bc4a

Please sign in to comment.