@andrewstart/av-encoder
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -41,5 +41,9 @@ "use strict"; | ||
await cache.load(); | ||
const destFolders = []; | ||
for (const group of config.audio.folders) { | ||
const destFolder = path.resolve(cwd, group.dest); | ||
await fs.ensureDir(destFolder); | ||
if (!destFolders.includes(destFolder)) { | ||
destFolders.push(destFolder); | ||
} | ||
const changed = await utils_1.filterChanged(await fast_glob_1.default(group.src, { cwd }), async (file) => { | ||
@@ -127,5 +131,19 @@ var _a; | ||
} | ||
cache.purgeUnseen(); | ||
const missing = cache.purgeUnseen(); | ||
await cache.save(); | ||
if (config.audio.removeMissing) { | ||
const exts = ['.mp3', '.opus', '.caf']; | ||
for (const file of missing) { | ||
const base = path.basename(file, path.extname(file)); | ||
for (const folder of destFolders) { | ||
for (const ext of exts) { | ||
const filePath = path.resolve(folder, base + ext); | ||
if (await fs.pathExists(filePath)) { | ||
await fs.remove(filePath); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
main(); |
@@ -44,5 +44,9 @@ "use strict"; | ||
await cache.load(); | ||
const destFolders = []; | ||
for (const group of config.video.folders) { | ||
const destFolder = path.resolve(cwd, group.dest); | ||
await fs.ensureDir(destFolder); | ||
if (!destFolders.includes(destFolder)) { | ||
destFolders.push(destFolder); | ||
} | ||
const changed = await utils_1.filterChanged(await fast_glob_1.default(group.src, { cwd }), async (file) => { | ||
@@ -116,5 +120,16 @@ var _a; | ||
} | ||
cache.purgeUnseen(); | ||
const missing = cache.purgeUnseen(); | ||
await cache.save(); | ||
if (config.audio.removeMissing) { | ||
for (const file of missing) { | ||
const base = path.basename(file, path.extname(file)); | ||
for (const folder of destFolders) { | ||
const filePath = path.resolve(folder, base + '.mp4'); | ||
if (await fs.pathExists(filePath)) { | ||
await fs.remove(filePath); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
main(); |
{ | ||
"name": "@andrewstart/av-encoder", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Encodes and compresses audio/video for widely supported web formats", | ||
@@ -5,0 +5,0 @@ "bin": { |
20452
375