diff --git a/main.js b/main.js index 0b3316b..f82a346 100644 --- a/main.js +++ b/main.js @@ -42,7 +42,7 @@ function createWindow() { })); // Open the DevTools. - // if (debug) + if (debug) { mainWindow.webContents.openDevTools(); } @@ -76,7 +76,8 @@ app.on('ready', () => { mainWindow_height = settings.get('mainWindow_height', 768); createWindow(); mainWindow.webContents.on('did-finish-load', () => { - mainWindow.webContents.send('argv', process.argv); + if (process.argv.length > 1) + mainWindow.webContents.send('argv', process.argv[1]); }); }); diff --git a/package.json b/package.json index ff1f020..03369ce 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A simple tool for Using Graphviz.", "main": "main.js", "scripts": { - "start": "electron .", + "start": "electron . \"C:\\Users\\jcf\\Desktop\\graph.dot\"", "dev": "electron . --debug", "test": "echo \"Error: no test specified\" && exit 1", "dist": "electron-builder -lw --publish always", diff --git a/src/graph.js b/src/graph.js index 93d80ee..a96df40 100644 --- a/src/graph.js +++ b/src/graph.js @@ -440,7 +440,14 @@ ipcRenderer.on('save_dot_file', () => { }); ipcRenderer.on('argv', (event, message) => { - console.log(message); + fs.stat(message, (err, stat) => { + if (stat && stat.isFile()) { + console.log(message) + try_to_read_dot_from_file(message); + } else { + console.log("Not a file."); + } + }) }); // ------- Menu -------