mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
ci: we can skip a single file uploading error when uploading a folder… (#50108)
* ci: we can skip a single file uploading error when uploading a folder in scripts/visual-regression/upload.js * chore: update
This commit is contained in:
parent
f56fee1333
commit
6202187d6b
@ -114,14 +114,13 @@ async function uploadFile(client, filePath, refValue) {
|
||||
}
|
||||
|
||||
async function boot() {
|
||||
const [filepath, refValue] = parseArgs(args);
|
||||
const [fileOrFolderName, refValue] = parseArgs(args);
|
||||
|
||||
const fileOrFolderName = filepath;
|
||||
// check if exists
|
||||
const filePath = path.resolve(process.cwd(), fileOrFolderName);
|
||||
const workspacePath = path.resolve(process.cwd(), fileOrFolderName);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.error('File not exists: %s', filePath);
|
||||
if (!fs.existsSync(workspacePath)) {
|
||||
console.error('File not exists: %s', workspacePath);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@ -133,28 +132,27 @@ async function boot() {
|
||||
});
|
||||
|
||||
// if is a file then upload it directly
|
||||
const stat = fs.statSync(filePath);
|
||||
const stat = fs.statSync(workspacePath);
|
||||
if (stat.isFile()) {
|
||||
const doUpload = uploadFile(client, filePath, refValue);
|
||||
const doUpload = uploadFile(client, workspacePath, refValue);
|
||||
try {
|
||||
await retry(doUpload, 3, 1000);
|
||||
} catch (err) {
|
||||
console.error('Uploading file failed after retry %s, error: %s', 3, err);
|
||||
console.error('Uploading file `%s` failed after retry %s, error: %s', fileOrFolderName, 3, err);
|
||||
process.exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
const fileList = await walkDir(filePath);
|
||||
const fileList = await walkDir(workspacePath);
|
||||
for (const file of fileList) {
|
||||
const doUpload = uploadFile(client, file, refValue);
|
||||
try {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await retry(doUpload, 3, 1000);
|
||||
} catch (err) {
|
||||
console.error('Uploading file failed after retry %s, error: %s', 3, err);
|
||||
process.exit(1);
|
||||
console.warn('Skip uploading file `%s` in folder `%s` failed after retry %s, error: %s', path.relative(workspacePath, file), fileOrFolderName, 3, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user