From e0ccb6c076156d3a6848da90af511f75a7593ee5 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 5 May 2021 11:56:12 +0000 Subject: [PATCH] fix(core): update --- test/test.ts | 14 ++++++++++++-- ts/smartnpm.classes.npmpackage.ts | 2 +- ts/smartnpm.classes.npmregistry.ts | 5 +++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/test/test.ts b/test/test.ts index 46604be..06bc971 100644 --- a/test/test.ts +++ b/test/test.ts @@ -37,11 +37,21 @@ tap.test('should get package from verdaccio', async () => { }); tap.test('should get a specific file from a package', async () => { - const bundleFile = await verdaccioRegistry.getFileFromPackage( + const wantedFile = await verdaccioRegistry.getFileFromPackage( '@pushrocks/websetup', 'ts/index.ts' ); - console.log(bundleFile.contentBuffer.toString()); + console.log(wantedFile.contentBuffer.toString()); +}); + +tap.test('should get a specific file from a package', async () => { + const wantedFiles = await verdaccioRegistry.getFilesFromPackage( + '@pushrocks/websetup', + 'ts/' + ); + for(const file of wantedFiles) { + console.log(file.path); + } }); tap.start(); diff --git a/ts/smartnpm.classes.npmpackage.ts b/ts/smartnpm.classes.npmpackage.ts index 9932cd1..416a01a 100644 --- a/ts/smartnpm.classes.npmpackage.ts +++ b/ts/smartnpm.classes.npmpackage.ts @@ -140,7 +140,7 @@ export class NpmPackage { // lets resolve with the wanted file done.resolve([fileArg]); subscription.unsubscribe(); - } else if(fileArg.path.startsWith(wantedFilePath)) { + } else if(!returnOnFirstArg && fileArg.path.startsWith(wantedFilePath)) { allMatchingFiles.push(fileArg); } }, diff --git a/ts/smartnpm.classes.npmregistry.ts b/ts/smartnpm.classes.npmregistry.ts index 395eb46..db82b21 100644 --- a/ts/smartnpm.classes.npmregistry.ts +++ b/ts/smartnpm.classes.npmregistry.ts @@ -78,11 +78,12 @@ export class NpmRegistry { } } - public async getFilesFromPackage(packageNameArg: string, filePath: string, optionsArg: { + public async getFilesFromPackage(packageNameArg: string, filePath: string, optionsArg?: { distTag?: string; version?: string; }): Promise { - return []; + const npmPackage = await this.getPackageInfo(packageNameArg); + return npmPackage.getFilesFromPackage(filePath, optionsArg); } public async getPackageAsSmartfileVirtualDir(packageNameArg: string): Promise {