diff --git a/src/RokuDeploy.spec.ts b/src/RokuDeploy.spec.ts index f34c411..5dd4593 100644 --- a/src/RokuDeploy.spec.ts +++ b/src/RokuDeploy.spec.ts @@ -1482,6 +1482,13 @@ describe('index', () => { expect(pkgPath).to.equal('pkgs//P6953175d5df120c0069c53de12515b9a.pkg'); }); + it('should return created pkg from SD card on success', async () => { + mockDoPostRequest(fakePluginPackageResponse); + + let pkgPath = await rokuDeploy.signExistingPackage(options); + expect(pkgPath).to.equal('pkgs/sdcard0/Pae6cec1eab06a45ca1a7f5b69edd3a20.pkg'); + }); + it('should return our fallback error if neither error or package link was detected', async () => { mockDoPostRequest(); await expectThrowsAsync( @@ -3790,3 +3797,39 @@ function getFakeResponseBody(messages: string): string { `; } + +const fakePluginPackageResponse = ` + + + + + + + Roku Development Kit + + + +
+
+ +
+
+
+Pae6cec1eab06a45ca1a7f5b69edd3a20.pkg
+ + + + + + +`; diff --git a/src/RokuDeploy.ts b/src/RokuDeploy.ts index 51dd340..73392a9 100644 --- a/src/RokuDeploy.ts +++ b/src/RokuDeploy.ts @@ -623,7 +623,13 @@ export class RokuDeploy { throw new errors.FailedDeviceResponseError(failedSearchMatches[1], results); } - let pkgSearchMatches = //.exec(results.body); + //grab the package url from the JSON on the page if it exists (https://regex101.com/r/1HUXgk/1) + let pkgSearchMatches = /"pkgPath"\s*:\s*"(.*?)"/.exec(results.body); + if (pkgSearchMatches) { + return pkgSearchMatches[1]; + } + //for some reason we couldn't find the pkgPath from json, look in the tag + pkgSearchMatches = //.exec(results.body); if (pkgSearchMatches) { return pkgSearchMatches[1]; }