@@ -2,28 +2,28 @@ const path = require('path');
22const fs = require ( 'fs' ) ;
33const jszip = require ( 'jszip' ) ;
44
5- const iconFile = path . join ( __dirname , '../ icon.png' ) ;
6- const pluginJSON = path . join ( __dirname , '../ plugin.json' ) ;
7- const distFolder = path . join ( __dirname , '../ dist' ) ;
5+ const iconFile = path . join ( __dirname , 'icon.png' ) ;
6+ const pluginJSON = path . join ( __dirname , 'plugin.json' ) ;
7+ const distFolder = path . join ( __dirname , 'dist' ) ;
88const json = JSON . parse ( fs . readFileSync ( pluginJSON , 'utf8' ) ) ;
99let readmeDotMd ;
1010let changelogDotMd ;
1111
1212if ( ! json . readme ) {
13- readmeDotMd = path . join ( __dirname , '../ readme.md' ) ;
13+ readmeDotMd = path . join ( __dirname , 'readme.md' ) ;
1414 if ( ! fs . existsSync ( readmeDotMd ) ) {
15- readmeDotMd = path . join ( __dirname , '../ README.md' ) ;
15+ readmeDotMd = path . join ( __dirname , 'README.md' ) ;
1616 }
1717}
1818
1919
2020if ( ! json . changelogs ) {
2121 if ( ! fs . existsSync ( changelogDotMd ) ) {
22- changelogDotMd = path . join ( __dirname , '../ CHANGELOG.md' ) ;
22+ changelogDotMd = path . join ( __dirname , 'CHANGELOG.md' ) ;
2323 }
2424
2525 if ( ! fs . existsSync ( changelogDotMd ) ) {
26- changelogDotMd = path . join ( __dirname , '../ changelog.md' ) ;
26+ changelogDotMd = path . join ( __dirname , 'changelog.md' ) ;
2727 }
2828}
2929
@@ -33,14 +33,19 @@ const zip = new jszip();
3333
3434zip . file ( 'icon.png' , fs . readFileSync ( iconFile ) ) ;
3535zip . file ( 'plugin.json' , fs . readFileSync ( pluginJSON ) ) ;
36- zip . file ( 'readme.md' , fs . readFileSync ( readmeDotMd ) ) ;
37- zip . file ( 'changelogs.md' , fs . readFileSync ( changelogDotMd ) ) ;
36+
37+ if ( readmeDotMd ) {
38+ zip . file ( "readme.md" , fs . readFileSync ( readmeDotMd ) ) ;
39+ }
40+ if ( changelogDotMd ) {
41+ zip . file ( "changelog.md" , fs . readFileSync ( changelogDotMd ) ) ;
42+ }
3843
3944loadFile ( '' , distFolder ) ;
4045
4146zip
4247 . generateNodeStream ( { type : 'nodebuffer' , streamFiles : true } )
43- . pipe ( fs . createWriteStream ( path . join ( __dirname , '../ plugin.zip' ) ) )
48+ . pipe ( fs . createWriteStream ( path . join ( __dirname , 'plugin.zip' ) ) )
4449 . on ( 'finish' , ( ) => {
4550 console . log ( 'Plugin plugin.zip written.' ) ;
4651 } ) ;
0 commit comments