bugfix #3997: react-native bundle not working on windows 10

Summary: fixes https://github.com/facebook/react-native/issues/3997

the root cause is in

Mon, 09 Nov 2015 13:22:47 GMT ReactNativePackager:SocketServer uncaught error Error: listen EACCES C:\Users\donald\AppData\Local\Temp\react-packager-9248a9803ac72b509b389b456696850d

This means that the socket server cannot create the socket.

cfr https://gist.github.com/domenic/2790533 the socket name is not a valid windows socket name.
Closes https://github.com/facebook/react-native/pull/4071

Reviewed By: mkonicek

Differential Revision: D2699546

Pulled By: davidaurelio

fb-gh-sync-id: 6c6494c14c42bb17506b8559001419c9f85e91e3
This commit is contained in:
Bram 2015-11-27 07:15:28 -08:00 committed by facebook-github-bot-4
parent efdc037859
commit df687d8442

View File

@ -35,10 +35,17 @@ const SocketInterface = {
}
});
const sockPath = path.join(
let sockPath = path.join(
tmpdir,
'react-packager-' + hash.digest('hex')
);
if (process.platform === 'win32'){
// on Windows, use a named pipe, convert sockPath into a valid pipe name
// based on https://gist.github.com/domenic/2790533
sockPath = sockPath.replace(/^\//, '')
sockPath = sockPath.replace(/\//g, '-')
sockPath = '\\\\.\\pipe\\' + sockPath
}
if (fs.existsSync(sockPath)) {
var sock = net.connect(sockPath);