Skip to content

Commit

Permalink
scripts: update file check
Browse files Browse the repository at this point in the history
  • Loading branch information
sylingd committed Jul 10, 2024
1 parent e976688 commit f002f52
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions scripts/release.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile, readdir, stat } from 'fs/promises';
import { readFile, readdir, access, constants } from 'fs/promises';
import { join } from 'path';
import { createHash } from 'crypto';
import { Blob } from 'buffer';
Expand Down Expand Up @@ -50,21 +50,24 @@ async function main() {
continue;
}
const fullPath = join(_path.release, file);
const statResult = await stat(fullPath);
if (statResult.isFile()) {
const fileContent = await readFile(fullPath);
const id = await readFile(join(_path.release, file + '-id.txt'), {
encoding: 'utf8',
});
assets.push({
id,
name: file,
path: fullPath,
hash: hash(fileContent),
content: fileContent,
url: `https://github.com/${repo}/releases/download/${tagName}/${file}`
});
try {
await access(fullPath, constants.R_OK);
} catch (e) {
// access file failed, skip it
continue;
}
const fileContent = await readFile(fullPath);
const id = await readFile(join(_path.release, file + '-id.txt'), {
encoding: 'utf8',
});
assets.push({
id,
name: file,
path: fullPath,
hash: hash(fileContent),
content: fileContent,
url: `https://github.com/${repo}/releases/download/${tagName}/${file}`
});
}

// Check if release is exists
Expand Down

0 comments on commit f002f52

Please sign in to comment.