Replace promise to async/await
This commit is contained in:
parent
efac88db4c
commit
cc20b0a7c0
|
@ -4,7 +4,7 @@ function np(mainWindow){
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
var ipc = electron.ipcMain;
|
var ipc = electron.ipcMain;
|
||||||
ipc.on('itunes', (e, args) => {
|
ipc.on('itunes', async (e, args) => {
|
||||||
//Verified on Windows
|
//Verified on Windows
|
||||||
console.log("Access");
|
console.log("Access");
|
||||||
if(args[0]=="set"){
|
if(args[0]=="set"){
|
||||||
|
@ -25,14 +25,15 @@ function np(mainWindow){
|
||||||
var platform=process.platform;
|
var platform=process.platform;
|
||||||
var bit=process.arch;
|
var bit=process.arch;
|
||||||
if(platform=="darwin"){
|
if(platform=="darwin"){
|
||||||
const nowplaying = require("itunes-nowplaying-mac")
|
try {
|
||||||
nowplaying.getRawData().then(function (value) {
|
const nowplaying = require("itunes-nowplaying-mac");
|
||||||
|
const value = await nowplaying.getRawData();
|
||||||
mainWindow.webContents.send('itunes-np', value);
|
mainWindow.webContents.send('itunes-np', value);
|
||||||
}).catch(function (error) {
|
} catch (error) {
|
||||||
// エラーを返す
|
// エラーを返す
|
||||||
console.error(error);
|
console.error(error);
|
||||||
mainWindow.webContents.send('itunes-np', error);
|
mainWindow.webContents.send('itunes-np', error);
|
||||||
});
|
}
|
||||||
}else{
|
}else{
|
||||||
var {NowPlaying,PlayerName} = require("nowplaying-node");
|
var {NowPlaying,PlayerName} = require("nowplaying-node");
|
||||||
var nppath=join(app.getPath("userData"), "nowplaying");
|
var nppath=join(app.getPath("userData"), "nowplaying");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user