UNPKG

1.78 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/main-process/update.js"],"names":["selfUpdate","logger","updating","info","stdio","newVersion","JSON","parse","__dirname","version","currentVersion","cwd","err","error","message"],"mappings":";;;;;QASgBA,U,GAAAA,U;;AAThB;;AACA;;AACA;;;;AACA;;AACA;;AACA;;;;AAEA,MAAMC,SAAS,0BAAW,YAAX,CAAf;;AAEO,SAASD,UAAT,GAAsB;AAC3B,0BAAW,EAAEE,UAAU,IAAZ,EAAX;AACAD,SAAOE,IAAP,CAAY,aAAZ;AACA,MAAI;AACF,iCAAS,+BAAT,EAA0C,EAAEC,OAAO,SAAT,EAA1C;AACA,UAAMC,aAAaC,KAAKC,KAAL,CAAW,sBAAc,GAAEC,SAAU,qBAA1B,CAAX,EAA4DC,OAA/E;AACAR,WAAOE,IAAP,CAAY,qBAAZ,EAAmC,EAAEE,UAAF,EAAcK,gCAAd,EAAnC;AACA,QAAIL,+BAAJ,EAAmC;AACjC,mCAAU,oBAAD,gBAAmC,MAAKA,UAAW,GAA5D,EAAgE;AAC9DD,eAAO,SADuD;AAE9DO,aAAKH;AAFyD,OAAhE;AAID;AACD;AACA,WAAO,IAAP;AACD,GAZD,CAYE,OAAOI,GAAP,EAAY;AACZX,WAAOY,KAAP,CAAaD,IAAIE,OAAjB;AACD;AACF","file":"update.js","sourcesContent":["import { readFileSync } from 'fs';\nimport { execSync } from 'child_process';\nimport Logger from 'nightingale';\nimport { version as currentVersion } from '../../package.json';\nimport { sendUpdate } from './client';\nimport { exit } from '../index';\n\nconst logger = new Logger('app:update');\n\nexport function selfUpdate() {\n sendUpdate({ updating: true });\n logger.info('self update');\n try {\n execSync('npm install -g pooliot-client', { stdio: 'inherit' });\n const newVersion = JSON.parse(readFileSync(`${__dirname}/../../package.json`)).version;\n logger.info('self update migrate', { newVersion, currentVersion });\n if (newVersion !== currentVersion) {\n execSync(`node migrate.js \"${currentVersion}\" \"${newVersion}\"`, {\n stdio: 'inherit',\n cwd: __dirname,\n });\n }\n exit();\n return true;\n } catch (err) {\n logger.error(err.message);\n }\n}\n"]}
\No newline at end of file