@mieweb/wikigdrive
Version:
Google Drive to MarkDown synchronization
46 lines (45 loc) • 1.56 kB
JavaScript
import { QueueTask } from '../google_folder/QueueTask.js';
import { generateRedirectMarkdown } from './frontmatters/generateRedirectMarkdown.js';
export class TaskRedirFileTransform extends QueueTask {
constructor(logger, realFileName, destinationDirectory, redirFile, localFile) {
super(logger);
Object.defineProperty(this, "logger", {
enumerable: true,
configurable: true,
writable: true,
value: logger
});
Object.defineProperty(this, "realFileName", {
enumerable: true,
configurable: true,
writable: true,
value: realFileName
});
Object.defineProperty(this, "destinationDirectory", {
enumerable: true,
configurable: true,
writable: true,
value: destinationDirectory
});
Object.defineProperty(this, "redirFile", {
enumerable: true,
configurable: true,
writable: true,
value: redirFile
});
Object.defineProperty(this, "localFile", {
enumerable: true,
configurable: true,
writable: true,
value: localFile
});
if (!this.localFile.fileName) {
throw new Error(`No fileName for: ${this.localFile.id}`);
}
}
async run() {
const md = generateRedirectMarkdown(this.redirFile, this.localFile);
await this.destinationDirectory.writeFile(this.realFileName, md);
return [];
}
}