@dumbdevs/scaffold-move
Version:
Scaffold generator for Movement Labs DApps in TypeScript
38 lines (37 loc) • 1.41 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
// Define the copyTemplates function
async function copyTemplates() {
const srcDir = path_1.default.join(__dirname, 'templates');
const destDir = path_1.default.join(__dirname, '..', 'dist', 'templates');
try {
// Ensure the source directory exists
if (!fs_extra_1.default.existsSync(srcDir)) {
throw new Error(`Source directory '${srcDir}' does not exist.`);
}
// Ensure the destination directory exists (create it if it doesn’t)
await fs_extra_1.default.ensureDir(destDir);
// Copy the templates directory to the destination
await fs_extra_1.default.copy(srcDir, destDir, { overwrite: true });
console.log(`Templates copied successfully from '${srcDir}' to '${destDir}'!`);
}
catch (err) {
console.error('Error copying templates:');
process.exit(1);
}
}
// Execute the function and handle top-level async
(async () => {
try {
await copyTemplates();
}
catch (err) {
console.error('Unexpected error:');
process.exit(1);
}
})();