"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.generatorCopyTpl = exports.generatorCopy = void 0; const path_1 = __importDefault(require("path")); /** * Takes in a file path in the `./templates` directory. Copies that * file to the destination, with the `.tpl` extension stripped. * * @param {Generator} generator A Yeoman Generator instance * @param {string} templateDir Absolute path to template directory * @returns {Function} A curried function that takes a file path and copies it */ const generatorCopy = (generator, templateDir) => (filePath) => { const sourceParts = templateDir.split(path_1.default.delimiter); sourceParts.push(...filePath.split('/')); const targetParts = path_1.default.dirname(filePath).split('/'); targetParts.push(path_1.default.basename(filePath, '.tpl')); generator.fs.copy(path_1.default.join(...sourceParts), generator.destinationPath(path_1.default.join.apply(null, targetParts))); }; exports.generatorCopy = generatorCopy; /** * Takes in a file path in the `./templates` directory. Copies that * file to the destination, with the `.tpl` extension and `_` prefix * stripped. Passes `this.props` to the template. * * @param {Generator} generator A Yeoman Generator instance * @param {string} templateDir Absolute path to template directory * @param {any} templateData An object containing the data passed to * the template files. * @returns {Function} A curried function that takes a file path and copies it */ const generatorCopyTpl = (generator, templateDir, templateData) => (filePath) => { const sourceParts = templateDir.split(path_1.default.delimiter); sourceParts.push(...filePath.split('/')); const targetParts = path_1.default.dirname(filePath).split('/'); targetParts.push(path_1.default.basename(filePath, '.tpl').slice(1)); generator.fs.copyTpl(path_1.default.join(...sourceParts), generator.destinationPath(path_1.default.join.apply(null, targetParts)), templateData); }; exports.generatorCopyTpl = generatorCopyTpl;