Last active
November 10, 2015 04:46
-
-
Save uupaa/1b05221c7c1874e4d438 to your computer and use it in GitHub Desktop.
chdir main and render process in Electron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var app = require("app"); | |
var BrowserWindow = require("browser-window"); | |
process.chdir("test/el"); // 作業ディレクトリ変えて | |
var cwd = process.cwd(); // cwd とっといて | |
require("crash-reporter").start(); | |
var mainWindow = null; | |
app.on("window-all-closed", function() { | |
if (process.platform !== "darwin") { app.quit(); } | |
}); | |
app.on("ready", function() { | |
mainWindow = new BrowserWindow({ width: 800, height: 600 }); | |
mainWindow.loadUrl("file://" + __dirname + "/index.html"); | |
// https://github.com/atom/electron/blob/master/docs/api/web-contents.md#event-did-finish-load | |
mainWindow.webContents.on("did-finish-load", function() { // window.onload done. | |
mainWindow.webContents.executeJavaScript("process.chdir(" + cwd + ")"); | |
}); | |
mainWindow.on("closed", function() { | |
mainWindow = null; | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment