fix(core): update
This commit is contained in:
@@ -48,9 +48,9 @@ export class NpmPackage {
|
||||
} = null;
|
||||
public searchScore: number = null;
|
||||
|
||||
public npmRegistry: NpmRegistry;
|
||||
public npmRegistryRef: NpmRegistry;
|
||||
constructor(npmRegistryArg: NpmRegistry) {
|
||||
this.npmRegistry = npmRegistryArg;
|
||||
this.npmRegistryRef = npmRegistryArg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,6 +58,38 @@ export class NpmPackage {
|
||||
*/
|
||||
public async saveToDisk(targetDir: string) {
|
||||
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
|
||||
await smartarchiveInstance.extractArchiveFromUrl(this.dist.tarball, targetDir);
|
||||
await smartarchiveInstance.extractArchiveFromUrlToFs(this.dist.tarball, targetDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* saves the package to memory
|
||||
*/
|
||||
public async saveToMemory() {}
|
||||
|
||||
/**
|
||||
* get file from package
|
||||
*/
|
||||
public async getFileFromPackage(filePath: string): Promise<plugins.smartfile.Smartfile> {
|
||||
const done = plugins.smartpromise.defer<plugins.smartfile.Smartfile>();
|
||||
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
|
||||
const fileObservable = await smartarchiveInstance.extractArchiveFromUrlToObservable(
|
||||
this.dist.tarball
|
||||
);
|
||||
const wantedFilePath = plugins.path.join('package', filePath);
|
||||
const subscription = fileObservable.subscribe(
|
||||
(fileArg) => {
|
||||
if (fileArg.path === wantedFilePath) {
|
||||
done.resolve(fileArg);
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
);
|
||||
return done.promise;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user