|
| 1 | +/* eslint no-console: error */ |
1 | 2 | import fs from 'node:fs/promises'; |
2 | 3 | import os from 'node:os'; |
3 | | -/* eslint no-console: error */ |
4 | 4 | import path from 'node:path'; |
5 | 5 | import process from 'node:process'; |
6 | 6 | import { Octokit } from '@octokit/rest'; |
7 | | -import AdmZip from 'adm-zip'; |
8 | 7 | import { consola } from 'consola'; |
9 | 8 | import debug from 'debug'; |
10 | 9 | import { dirname } from 'dirname-filename-esm'; |
11 | 10 | import { $ } from 'execa'; |
| 11 | +import * as fflate from 'fflate'; |
12 | 12 | import { got } from 'got'; |
13 | 13 | import isInCi from 'is-in-ci'; |
14 | 14 | import md5 from 'md5'; |
@@ -50,16 +50,22 @@ try { |
50 | 50 | throw new Error('Download vsix failed'); |
51 | 51 | } |
52 | 52 |
|
53 | | - const zip = new AdmZip(currentVsix); |
54 | | - const zipEntries = zip.getEntries(); |
55 | | - const entry = zipEntries.find( |
56 | | - o => o.entryName === `extension/dist/${phpfmt.v2.pharName}` |
57 | | - ); |
58 | | - if (entry == null) { |
| 53 | + const zipData = await new Promise<fflate.Unzipped>((resolve, reject) => { |
| 54 | + fflate.unzip(new Uint8Array(currentVsix), (err, data) => { |
| 55 | + if (err) { |
| 56 | + reject(err); |
| 57 | + } else { |
| 58 | + resolve(data); |
| 59 | + } |
| 60 | + }); |
| 61 | + }); |
| 62 | + |
| 63 | + const entryPath = `extension/dist/${phpfmt.v2.pharName}`; |
| 64 | + if (!(entryPath in zipData)) { |
59 | 65 | throw new Error('Not found phar in vsix'); |
60 | 66 | } |
61 | 67 |
|
62 | | - const currentPharData = String(entry.getData()); |
| 68 | + const currentPharData = new TextDecoder().decode(zipData[entryPath]); |
63 | 69 | const currentMd5 = md5(currentPharData); |
64 | 70 | consola.info(`Current md5: ${currentMd5}`); |
65 | 71 |
|
|
0 commit comments