@@ -18,10 +18,8 @@ async function main() {
1818
1919 const branch : string = process . argv [ 2 ]
2020
21- let type : 'scratch' | undefined = process . argv [ 3 ] as any
22- if ( type != 'scratch' && type !== undefined ) {
23- throw new Error ( `Invalid second arguemnt: "${ type } "\n` )
24- }
21+ const isFromScratch = process . argv [ 3 ] == 'scratch'
22+ const changedModIds = process . argv [ 3 ] ?. split ( ',' ) ?? [ ]
2523
2624 const repoBranches = await getRepoBranches ( )
2725 if ( ! repoBranches . includes ( branch ) ) {
@@ -35,7 +33,8 @@ async function main() {
3533 }
3634
3735 await createNpDatabase (
38- type == 'scratch' ,
36+ isFromScratch ,
37+ changedModIds ,
3938 ( path : string ) => gitReadFunc ( branch , path ) ,
4039 gitWriteFunc
4140 )
@@ -51,7 +50,12 @@ async function main() {
5150 )
5251}
5352
54- async function createNpDatabase ( fromScratch : boolean , read : ReadFunc , write : WriteFunc ) {
53+ async function createNpDatabase (
54+ fromScratch : boolean ,
55+ changedModIds : string [ ] ,
56+ read : ReadFunc ,
57+ write : WriteFunc
58+ ) {
5559 const locations = await readInputLocations ( read )
5660
5761 let dbToMerge : PackageDB = { }
@@ -67,16 +71,19 @@ async function createNpDatabase(fromScratch: boolean, read: ReadFunc, write: Wri
6771 if ( fromScratch ) {
6872 inputLocationsToFetch = Object . values ( locations )
6973 } else {
70- for ( const modId in locations ) {
74+ for ( const modId of changedModIds ) {
7175 const loc = locations [ modId ]
72- if ( loc . type === undefined || loc . type == 'zip' ) {
73- if ( loc . changed ) inputLocationsToFetch . push ( loc )
74- }
76+ if ( ! loc ) throw new Error ( `mod: "${ modId } " not found in input-locations.json` )
77+ inputLocationsToFetch . push ( loc )
7578 }
7679 for ( const modId in oldDb ) {
7780 if ( ! locations [ modId ] ) delete oldDb [ modId ]
7881 }
7982 }
83+ if ( inputLocationsToFetch . length == 0 ) {
84+ console . log ( 'no input locations specified' )
85+ process . exit ( 1 )
86+ }
8087
8188 const packages = await Promise . all ( inputLocationsToFetch . map ( loc => source . get ( loc , write ) ) )
8289
0 commit comments