]> khamidou — GitHub mirrors - electron.git/commitdiff
Make __filename normalized
authorCheng Zhao <zcbenz@gmail.com>
Tue, 14 Oct 2014 11:45:57 +0000 (19:45 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 14 Oct 2014 11:45:57 +0000 (19:45 +0800)
This can make sure __filename and __dirname on Windows use "\" as path
delimeter.

atom/renderer/lib/init.coffee
spec/api-ipc-spec.coffee

index a6f571b213cd485a2800fdeab5c771877905af7a..ac11ac0d3418db03521a4abf2d5ce64471b0e287 100644 (file)
@@ -35,7 +35,7 @@ if window.location.protocol in ['file:', 'asar:']
       window.location.pathname.substr 1
     else
       window.location.pathname
-  global.__filename = decodeURIComponent pathname
+  global.__filename = path.normalize decodeURIComponent(pathname)
   global.__dirname = path.dirname global.__filename
 
   # Set module's filename so relative require can work as expected.
index 86dbe810cff6265c67516d17977b812e0a0d05bb..c63997af7e784c0e0d86fb7a7824ec5991cf222b 100644 (file)
@@ -19,8 +19,8 @@ describe 'ipc module', ->
       assert.equal a.id, 1127
 
     it 'should search module from the user app', ->
-      assert.equal remote.process.mainModule.filename, path.resolve(__dirname, 'static', 'main.js')
-      assert.equal remote.process.mainModule.paths[0], path.resolve(__dirname, 'static', 'node_modules')
+      assert.equal path.normalize(remote.process.mainModule.filename), path.resolve(__dirname, 'static', 'main.js')
+      assert.equal path.normalize(remote.process.mainModule.paths[0]), path.resolve(__dirname, 'static', 'node_modules')
 
   describe 'remote.createFunctionWithReturnValue', ->
     it 'should be called in browser synchronously', ->