diff --git a/test/test.ts b/test/test.ts index 4d6e193..3cdd02b 100644 --- a/test/test.ts +++ b/test/test.ts @@ -11,13 +11,15 @@ const testPlugins = { }; const testPaths = { - nogitDir: testPlugins.path.join(process.cwd(), '.nogit/') + nogitDir: testPlugins.path.join(process.cwd(), '.nogit/'), + remoteDir: testPlugins.path.join(process.cwd(), '.nogit/remote') }; import * as smartarchive from '../ts/index'; tap.preTask('should prepare .nogit dir', async () => { await testPlugins.smartfile.fs.ensureDir(testPaths.nogitDir); + await testPlugins.smartfile.fs.ensureDir(testPaths.remoteDir); }); tap.preTask('should prepare downloads', async tools => { @@ -40,4 +42,10 @@ tap.test('should extract files on disk', async () => { ); }); +tap.test('should download a package from the registry', async () => { + const testSmartarchive = new smartarchive.SmartArchive(); + await testSmartarchive.extractArchiveFromUrl('https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.11.tgz', testPaths.remoteDir); + +}); + tap.start(); diff --git a/ts/smartarchive.classes.smartarchive.ts b/ts/smartarchive.classes.smartarchive.ts index abb2cf0..087c1a1 100644 --- a/ts/smartarchive.classes.smartarchive.ts +++ b/ts/smartarchive.classes.smartarchive.ts @@ -12,13 +12,10 @@ export class SmartArchive { const parsedPath = plugins.path.parse(urlArg); const uniqueFileName = plugins.smartunique.uni() + parsedPath.ext; const downloadPath = plugins.path.join(paths.nogitDir, uniqueFileName); - const downloadedArchive = ( - await plugins.smartrequest.getBinary( - 'https://verdaccio.lossless.one/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz' - ) - ).body; + const downloadedArchive = (await plugins.smartrequest.getBinary(urlArg)).body; await plugins.smartfile.memory.toFs(downloadedArchive, downloadPath); await this.extractArchiveFromFilePath(downloadPath, targetDir); + await plugins.smartfile.fs.remove(downloadPath); } /**