@@ -7175,79 +7175,106 @@ const core = __importStar(__nccwpck_require__(2186));
71757175const exec = __importStar ( __nccwpck_require__ ( 1514 ) ) ;
71767176const tc = __importStar ( __nccwpck_require__ ( 7784 ) ) ;
71777177const fs_1 = __importDefault ( __nccwpck_require__ ( 7147 ) ) ;
7178+ /**
7179+ * Return a Emacs zip path.
7180+ */
7181+ function downloadEmacsZip ( base , version ) {
7182+ const ver_lst = version . split ( "." ) ; // if 27.1
7183+ const emacs_major_ver = ver_lst [ 0 ] ; // 27
7184+ const emacs_minor_ver = ver_lst [ 1 ] ; // 1
7185+ const dot_ver = emacs_major_ver + "." + emacs_minor_ver ; // 27.1
7186+ const dash_ver = emacs_major_ver + "-" + emacs_minor_ver ; // 27-1
7187+ const emacs_dot_var = "emacs-" + dot_ver ; // emacs-27.1
7188+ let ftpUrl = base + "emacs-" + emacs_major_ver + "/" ;
7189+ let zipPath = ftpUrl + emacs_dot_var ;
7190+ if ( version == "snapshot" ) {
7191+ // NOTE: If snapshot, directly assign the newest version.
7192+ // Current newest snaptshot is `30.0.50`.
7193+ zipPath = "https://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-30/emacs-30.1.90_1.zip" ;
7194+ }
7195+ else {
7196+ switch ( dot_ver ) {
7197+ case "22.3" :
7198+ case "23.4" :
7199+ case "24.1" :
7200+ case "24.2" :
7201+ case "24.3" : {
7202+ zipPath += "-bin-i386.zip" ;
7203+ break ;
7204+ }
7205+ case "24.4" : {
7206+ zipPath += "-bin-i686-pc-mingw32.zip" ;
7207+ break ;
7208+ }
7209+ case "24.5" : {
7210+ zipPath += "-bin-i686-mingw32.zip" ;
7211+ break ;
7212+ }
7213+ case "25.1" : {
7214+ zipPath += "-x86_64-w64-mingw32.zip" ;
7215+ break ;
7216+ }
7217+ case "25.2" :
7218+ case "25.3" :
7219+ case "26.1" :
7220+ case "26.2" :
7221+ case "26.3" :
7222+ case "27.1" :
7223+ case "27.2" : {
7224+ zipPath += "-x86_64.zip" ;
7225+ break ;
7226+ }
7227+ case "28.1" :
7228+ case "28.2" :
7229+ case "29.1" :
7230+ case "29.2" :
7231+ case "29.3" :
7232+ case "29.4" :
7233+ case "30.1" :
7234+ case "30.2" : {
7235+ zipPath += ".zip" ;
7236+ break ;
7237+ }
7238+ default : {
7239+ zipPath += "-x86_64.zip" ;
7240+ break ;
7241+ }
7242+ }
7243+ }
7244+ return zipPath ;
7245+ }
7246+ /**
7247+ * Attempt to download Emacs, else return null.
7248+ */
7249+ function downloadEmacs ( base , version ) {
7250+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
7251+ let zipPath = downloadEmacsZip ( base , version ) ;
7252+ try {
7253+ return tc . downloadTool ( zipPath ) ;
7254+ }
7255+ catch ( err ) {
7256+ return null ;
7257+ }
7258+ } ) ;
7259+ }
7260+ /**
7261+ * Action entry.
7262+ */
71787263function run ( ) {
7264+ var _a ;
71797265 return __awaiter ( this , void 0 , void 0 , function * ( ) {
71807266 try {
71817267 const PATH = process . env . PATH ;
71827268 const version = core . getInput ( "version" ) ;
7183- const ver_lst = version . split ( "." ) ; // if 27.1
7184- const emacs_major_ver = ver_lst [ 0 ] ; // 27
7185- const emacs_minor_ver = ver_lst [ 1 ] ; // 1
7186- const dot_ver = emacs_major_ver + "." + emacs_minor_ver ; // 27.1
7187- const dash_ver = emacs_major_ver + "-" + emacs_minor_ver ; // 27-1
7188- const emacs_dot_var = "emacs-" + dot_ver ; // emacs-27.1
7189- core . startGroup ( "Installing Emacs" ) ;
7190- let ftpUrl = "https://ftp.gnu.org/gnu/emacs/windows/emacs-" + emacs_major_ver + "/" ;
7191- let zipPath = ftpUrl + emacs_dot_var ;
7192- if ( version == "snapshot" ) {
7193- // NOTE: If snapshot, directly assign the newest version.
7194- // Current newest snaptshot is `30.0.50`.
7195- zipPath = "https://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-30/emacs-30.1.90_1.zip" ;
7196- }
7197- else {
7198- switch ( dot_ver ) {
7199- case "22.3" :
7200- case "23.4" :
7201- case "24.1" :
7202- case "24.2" :
7203- case "24.3" : {
7204- zipPath += "-bin-i386.zip" ;
7205- break ;
7206- }
7207- case "24.4" : {
7208- zipPath += "-bin-i686-pc-mingw32.zip" ;
7209- break ;
7210- }
7211- case "24.5" : {
7212- zipPath += "-bin-i686-mingw32.zip" ;
7213- break ;
7214- }
7215- case "25.1" : {
7216- zipPath += "-x86_64-w64-mingw32.zip" ;
7217- break ;
7218- }
7219- case "25.2" :
7220- case "25.3" :
7221- case "26.1" :
7222- case "26.2" :
7223- case "26.3" :
7224- case "27.1" :
7225- case "27.2" : {
7226- zipPath += "-x86_64.zip" ;
7227- break ;
7228- }
7229- case "28.1" :
7230- case "28.2" :
7231- case "29.1" :
7232- case "29.2" :
7233- case "29.3" :
7234- case "29.4" :
7235- case "30.1" :
7236- case "30.2" : {
7237- zipPath += ".zip" ;
7238- break ;
7239- }
7240- default : {
7241- zipPath += "-x86_64.zip" ;
7242- break ;
7243- }
7244- }
7269+ const emacsZip = ( _a = yield downloadEmacs ( "https://ftp.gnu.org/gnu/emacs/windows/" , version ) ) !== null && _a !== void 0 ? _a : yield downloadEmacs ( "https://ftp.man.poznan.pl/gnu/emacs/windows/" , version ) ;
7270+ if ( ! emacsZip ) {
7271+ throw new Error ( "Failed to download Emacs from all sources." ) ;
72457272 }
7273+ // Setup extract path.
72467274 const extractPath = "c:\\emacs" ;
72477275 if ( ! fs_1 . default . existsSync ( extractPath ) ) {
72487276 fs_1 . default . mkdirSync ( extractPath ) ;
72497277 }
7250- const emacsZip = yield tc . downloadTool ( zipPath ) ;
72517278 const emacsDir = yield tc . extractZip ( emacsZip , extractPath ) ;
72527279 let emacsRoot = emacsDir ;
72537280 let emacsBin = emacsRoot + "\\bin" ;
0 commit comments