File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -150,22 +150,28 @@ class Packages {
150150
151151 /**
152152 * Reads package manifests
153+ * @param {string[] } paths
154+ * @param {object } user
153155 * @return {Package[] } List of packages
154156 */
155- async readPackageManifests ( user ) {
157+ async readPackageManifests ( paths , user ) {
156158 const { realpath} = this . core . make ( 'osjs/vfs' ) ;
157159 const { manifestFile} = this . options ;
158- const homePath = await realpath ( 'home:/.packages/metadata.json' , user ) ;
159-
160160 const systemManifest = await readOrDefault ( manifestFile ) ;
161- const userManifest = await readOrDefault ( homePath ) ;
161+
162+ const userManifests = await Promise . all ( paths . map ( async p => {
163+ const real = await realpath ( `${ p } /metadata.json` , user ) ;
164+ const list = await readOrDefault ( real ) ;
165+
166+ return list . map ( pkg => Object . assign ( { } , pkg , {
167+ _vfs : p ,
168+ server : null
169+ } ) ) ;
170+ } ) ) ;
162171
163172 return [
164173 ...systemManifest ,
165- ...userManifest . map ( pkg => Object . assign ( { } , pkg , {
166- _user : true ,
167- server : null
168- } ) )
174+ ...[ ] . concat ( ...userManifests )
169175 ] ;
170176 }
171177
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ class PackageServiceProvider extends ServiceProvider {
7272 this . core . singleton ( 'osjs/packages' , ( ) => this . packages ) ;
7373
7474 routeAuthenticated ( 'GET' , '/api/packages/manifest' , ( req , res ) => {
75- this . packages . readPackageManifests ( req . session . user )
75+ this . packages . readPackageManifests ( req . query . root || [ ] , req . session . user )
7676 . then ( json => res . json ( json ) )
7777 . catch ( error => res . status ( 400 ) . json ( { error} ) ) ;
7878 } ) ;
You can’t perform that action at this time.
0 commit comments