From 17eda1e56ad92011f70c2932fecd110d5790161b Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Mon, 19 Apr 2021 12:12:48 +0000 Subject: [PATCH] fix(core): update --- test/test.ts | 19 +++++++++++++++++-- ts/smartarchive.classes.smartarchive.ts | 11 +++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/test.ts b/test/test.ts index 0a51881..d4178a5 100644 --- a/test/test.ts +++ b/test/test.ts @@ -49,7 +49,8 @@ tap.test('should download a package from the registry', async () => { ); }); -tap.test('should extract a package using tarStream', async () => { +tap.test('should extract a package using tarStream', async (tools) => { + const done = tools.defer(); const testSmartarchive = new smartarchive.SmartArchive(); const testTgzBuffer = ( await testPlugins.smartfile.Smartfile.fromFilePath( @@ -61,8 +62,22 @@ tap.test('should extract a package using tarStream', async () => { ); const subscription = extractionFileObservable.subscribe(file => { console.log(file.path); - }); + await tools.delayFor(2000); + done.resolve(); + await done.promise; +}); + +tap.test('should extract a file from url to replaySubject', async (tools) => { + const done = tools.defer(); + const testSmartarchive = new smartarchive.SmartArchive(); + const extractionFileObservable = await testSmartarchive.extractArchiveFromUrlToObservable('https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'); + const subscription = extractionFileObservable.subscribe(file => { + console.log(file.path); + }); + await tools.delayFor(2000); + done.resolve(); + await done.promise; }); tap.start(); diff --git a/ts/smartarchive.classes.smartarchive.ts b/ts/smartarchive.classes.smartarchive.ts index df64659..7009903 100644 --- a/ts/smartarchive.classes.smartarchive.ts +++ b/ts/smartarchive.classes.smartarchive.ts @@ -78,4 +78,15 @@ export class SmartArchive { intake.signalEnd(); return replaySubject; } + + /** + * extracts to Observable + */ + public async extractArchiveFromUrlToObservable( + urlArg: string + ): Promise> { + const response = await plugins.smartrequest.getBinary(urlArg); + const replaySubject = this.extractArchiveFromBufferToObservable(response.body); + return replaySubject; + } }