UNPKG

md-curcuma

Version:

A Typescript library for transporting and converting markdown and other data.

41 lines (40 loc) 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CopyJob = void 0; const filesystem_1 = require("./filesystem"); const MD_Template_1 = require("../tasks/markdown/helpers/MD_Template"); class CopyJob { static perform(copy_task, template_values) { if (copy_task !== undefined && copy_task !== null) { const source_path = copy_task.source.trim(); const source_filename = template_values.name_full.trim(); var target_path = copy_task.target.trim(); const target_filename = template_values.name_full.trim(); const source = filesystem_1.Filesystem.concat_path_filename(source_path, source_filename); const template = new MD_Template_1.MD_Template(target_path); target_path = template.fill(template_values); filesystem_1.Filesystem.ensure_path(target_path, copy_task.simulate); var target = filesystem_1.Filesystem.concat_path_filename(target_path, target_filename); filesystem_1.Filesystem.copy_file(source, target, copy_task.simulate); } else { console.log("copy_task: ist not defined."); } } static hasCopyTask(obj) { if (obj.copy_task === undefined || obj.copy_task === null) { return false; } else return true; } static toString(obj) { if (CopyJob.hasCopyTask(obj)) { return `simulate:${obj.copy_task.simulate}, source:'${obj.copy_task.source}', target:'${obj.copy_task.target}'`; } else { return "no copy_task defined."; } } } exports.CopyJob = CopyJob;