Update .gitignore, add dist directory
This commit is contained in:
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
import fs from "fs";
|
||||
import grabDBDir from "./grab-db-dir";
|
||||
function stripExportExtension(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);
|
||||
return name;
|
||||
}
|
||||
function exportTimestamp(name) {
|
||||
const base = stripExportExtension(name);
|
||||
const ts = Number(base.split("-").pop());
|
||||
return Number.isFinite(ts) ? ts : 0;
|
||||
}
|
||||
export default function grabSortedExports({ config }) {
|
||||
const { export_dir } = grabDBDir({ config });
|
||||
if (!fs.existsSync(export_dir)) {
|
||||
return [];
|
||||
}
|
||||
const exports = fs.readdirSync(export_dir);
|
||||
return exports.sort((a, b) => exportTimestamp(b) - exportTimestamp(a));
|
||||
}
|
||||
Reference in New Issue
Block a user