diff --git a/bootstrap.ts b/bootstrap.ts index 8b8dbd03..1e9f9259 100644 --- a/bootstrap.ts +++ b/bootstrap.ts @@ -103,7 +103,7 @@ $injector.requireCommand("proxy|set", "./commands/proxy/proxy-set"); $injector.requireCommand("proxy|clear", "./commands/proxy/proxy-clear"); $injector.require("utils", "./utils"); -$injector.require("bplistParser", "./bplist-parser"); +$injector.require("plistParser", "./plist-parser"); $injector.require("winreg", "./winreg"); $injector.require("loggingLevels", "./mobile/logging-levels"); diff --git a/bplist-parser.ts b/bplist-parser.ts deleted file mode 100644 index 9e3a704d..00000000 --- a/bplist-parser.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as bplistParser from "bplist-parser"; - -export class BPlistParser implements IBinaryPlistParser { - - public async parseFile(plistFilePath: string): Promise { - return new Promise((resolve, reject) => { - bplistParser.parseFile(plistFilePath, (err: Error, obj: any) => { - if (err) { - reject(err); - } else { - resolve(obj); - } - }); - }); - } -} -$injector.register("bplistParser", BPlistParser); diff --git a/declarations.d.ts b/declarations.d.ts index ed6c3119..6d1ae9e5 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -1365,8 +1365,17 @@ interface IUtils { getMilliSecondsTimeout(defaultTimeout: number): number; } -interface IBinaryPlistParser { +/** + * Used for parsing of .plist files + */ +interface IPlistParser { + /** + * Parses the .plist file and returns the result as object + * @param {string} plistFilePath Absolute path to .plist file + * @return {Promise} The parsed object + */ parseFile(plistFilePath: string): Promise; + parseFileSync(plistFilePath: string): any; } interface IUserSettingsService extends UserSettings.IUserSettingsService { diff --git a/definitions/bplist-parser.d.ts b/definitions/bplist-parser.d.ts deleted file mode 100644 index 1999d7fa..00000000 --- a/definitions/bplist-parser.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module "bplist-parser" { - export function parseBuffer(buff: NodeBuffer): any; - export function parseFile(plistFilePath: string, callback?:(err: Error, obj: any) => void): any; -} diff --git a/definitions/simple-plist.d.ts b/definitions/simple-plist.d.ts new file mode 100644 index 00000000..e4df9bf6 --- /dev/null +++ b/definitions/simple-plist.d.ts @@ -0,0 +1,4 @@ +declare module "simple-plist" { + export function readFile(filePath: string, callback?:(err: Error, obj: any) => void): void; + export function readFileSync(filePath: string): any; +} \ No newline at end of file diff --git a/mobile/ios/simulator/ios-simulator-application-manager.ts b/mobile/ios/simulator/ios-simulator-application-manager.ts index bb1e4ff1..d3e78175 100644 --- a/mobile/ios/simulator/ios-simulator-application-manager.ts +++ b/mobile/ios/simulator/ios-simulator-application-manager.ts @@ -8,7 +8,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { private identifier: string, private $options: ICommonOptions, private $fs: IFileSystem, - private $bplistParser: IBinaryPlistParser, + private $plistParser: IPlistParser, private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider, private $deviceLogProvider: Mobile.IDeviceLogProvider, $logger: ILogger, @@ -90,7 +90,7 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { const applicationPath = this.iosSim.getApplicationPath(this.identifier, appIdentifier), pathToInfoPlist = path.join(applicationPath, "Info.plist"); - return this.$fs.exists(pathToInfoPlist) ? (await this.$bplistParser.parseFile(pathToInfoPlist))[0] : null; + return this.$fs.exists(pathToInfoPlist) ? await this.$plistParser.parseFile(pathToInfoPlist) : null; } public async getDebuggableApps(): Promise { diff --git a/package.json b/package.json index 5e5c9a1b..72dea5a7 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "Proton" ], "dependencies": { - "bplist-parser": "0.0.6", "bufferpack": "0.0.6", "byline": "4.2.1", "chalk": "1.0.0", @@ -63,6 +62,7 @@ "rimraf": "2.2.6", "semver": "5.3.0", "shelljs": "0.7.5", + "simple-plist": "0.2.1", "source-map": "0.5.6", "tabtab": "https://github.com/Icenium/node-tabtab/tarball/master", "temp": "0.8.1", diff --git a/plist-parser.ts b/plist-parser.ts new file mode 100644 index 00000000..39b64274 --- /dev/null +++ b/plist-parser.ts @@ -0,0 +1,20 @@ +import * as simplePlist from "simple-plist"; + +export class PlistParser implements IPlistParser { + public parseFile(plistFilePath: string): Promise { + return new Promise((resolve, reject) => { + simplePlist.readFile(plistFilePath, (err: Error, obj: any) => { + if (err) { + reject(err); + } else { + resolve(obj); + } + }); + }); + } + + public parseFileSync(plistFilePath: string): any { + return simplePlist.readFileSync(plistFilePath); + } +} +$injector.register("plistParser", PlistParser);