@@ -21,22 +21,27 @@ export async function execFile(...args: Parameters<typeof execFileWithoutLogging
21
21
22
22
/**
23
23
* Create a directory containing the contents of the to-be-generated tarball/zip.
24
+ *
25
+ * The tarball/zip will contain a top-level folder that will then contain all files instead of
26
+ * have all files directly in the archive.
24
27
*/
25
- export async function createCompressedArchiveContents ( pkg : PackageInformation ) : Promise < string > {
26
- // For the tarball and the zip file: We put license and readme texts at the
27
- // root of the package, and put all binaries into /bin.
28
+ export async function createCompressedArchiveContents ( archiveRootName : string , pkg : PackageInformation ) : Promise < string > {
29
+ // For the tarball and the zip file:
30
+ // - We add a single top-level folder to contain all contents
31
+ // - We put license and readme texts directly in the top-level folder, and put all binaries into folder/bin.
28
32
const tmpDir = path . join ( __dirname , '..' , '..' , '..' , 'tmp' , `pkg-${ Date . now ( ) } -${ Math . random ( ) } ` ) ;
29
- await fs . mkdir ( tmpDir , { recursive : true } ) ;
33
+ const archiveRoot = path . join ( tmpDir , archiveRootName ) ;
34
+ await fs . mkdir ( archiveRoot , { recursive : true } ) ;
30
35
const docFiles = [
31
36
...pkg . otherDocFilePaths ,
32
37
...pkg . binaries . map ( ( { license } ) => license )
33
38
] ;
34
39
for ( const { sourceFilePath, packagedFilePath } of docFiles ) {
35
- await fs . copyFile ( sourceFilePath , path . join ( tmpDir , packagedFilePath ) , COPYFILE_FICLONE ) ;
40
+ await fs . copyFile ( sourceFilePath , path . join ( archiveRoot , packagedFilePath ) , COPYFILE_FICLONE ) ;
36
41
}
37
- await fs . mkdir ( path . join ( tmpDir , 'bin' ) ) ;
42
+ await fs . mkdir ( path . join ( archiveRoot , 'bin' ) ) ;
38
43
for ( const { sourceFilePath } of pkg . binaries ) {
39
- await fs . copyFile ( sourceFilePath , path . join ( tmpDir , 'bin' , path . basename ( sourceFilePath ) ) , COPYFILE_FICLONE ) ;
44
+ await fs . copyFile ( sourceFilePath , path . join ( archiveRoot , 'bin' , path . basename ( sourceFilePath ) ) , COPYFILE_FICLONE ) ;
40
45
}
41
46
return tmpDir ;
42
47
}
0 commit comments