Update .gitignore, add dist directory
This commit is contained in:
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Strip known backup/export extensions from a file name.
|
||||
*/
|
||||
function stripBackupExtension(name) {
|
||||
const lower = name.toLowerCase();
|
||||
if (lower.endsWith(".tar.gz")) {
|
||||
return name.slice(0, -7);
|
||||
}
|
||||
if (lower.endsWith(".tgz")) {
|
||||
return name.slice(0, -4);
|
||||
}
|
||||
if (lower.endsWith(".tar")) {
|
||||
return name.slice(0, -4);
|
||||
}
|
||||
if (lower.endsWith(".zip")) {
|
||||
return name.slice(0, -4);
|
||||
}
|
||||
if (lower.endsWith(".sql")) {
|
||||
return name.slice(0, -4);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Parse timestamped backup/export names: `{db_name}-{timestamp}[.sql|.tar.gz|...]`
|
||||
*/
|
||||
export default function grabBackupData({ backup_name }) {
|
||||
const normalized = stripBackupExtension(backup_name);
|
||||
const backup_parts = normalized.split("-");
|
||||
const backup_date_timestamp = Number(backup_parts.pop());
|
||||
const origin_backup_name = backup_parts.join("-");
|
||||
const backup_date = new Date(backup_date_timestamp);
|
||||
return { backup_date, backup_date_timestamp, origin_backup_name };
|
||||
}
|
||||
Reference in New Issue
Block a user