From cc20b0a7c0591afb0fe1e4cd8429b4071e273cd0 Mon Sep 17 00:00:00 2001 From: kPherox Date: Sun, 14 Apr 2019 01:33:00 +0900 Subject: [PATCH] Replace promise to async/await --- app/main/np.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/main/np.js b/app/main/np.js index 352add5f..43668da6 100644 --- a/app/main/np.js +++ b/app/main/np.js @@ -4,7 +4,7 @@ function np(mainWindow){ const app = electron.app; const fs = require("fs"); var ipc = electron.ipcMain; - ipc.on('itunes', (e, args) => { + ipc.on('itunes', async (e, args) => { //Verified on Windows console.log("Access"); if(args[0]=="set"){ @@ -25,14 +25,15 @@ function np(mainWindow){ var platform=process.platform; var bit=process.arch; if(platform=="darwin"){ - const nowplaying = require("itunes-nowplaying-mac") - nowplaying.getRawData().then(function (value) { + try { + const nowplaying = require("itunes-nowplaying-mac"); + const value = await nowplaying.getRawData(); mainWindow.webContents.send('itunes-np', value); - }).catch(function (error) { + } catch (error) { // エラーを返す console.error(error); mainWindow.webContents.send('itunes-np', error); - }); + } }else{ var {NowPlaying,PlayerName} = require("nowplaying-node"); var nppath=join(app.getPath("userData"), "nowplaying");