UNPKG

zz-shopify-components

Version:

Reusable Shopify components for theme projects

40 lines (32 loc) • 1.1 kB
#!/usr/bin/env node console.log('Running postinstall...'); const fs = require('fs'); const path = require('path'); const PACKAGE_ROOT = path.resolve(__dirname, '..'); const PROJECT_ROOT = process.cwd(); const folders = ['sections', 'blocks', 'snippets', 'assets']; function copyDir(src, dest) { if (!fs.existsSync(src)) return; if (!fs.existsSync(dest)) { fs.mkdirSync(dest, { recursive: true }); } const items = fs.readdirSync(src); for (const item of items) { const srcPath = path.join(src, item); const destPath = path.join(dest, item); const stat = fs.statSync(srcPath); if (stat.isDirectory()) { copyDir(srcPath, destPath); } else { fs.copyFileSync(srcPath, destPath); // 覆盖 console.log(`āœ… Copied: ${path.relative(PROJECT_ROOT, destPath)}`); } } } console.log('\n🧩 [component-lib] Start syncing components to project...'); for (const folder of folders) { const from = path.join(PACKAGE_ROOT, folder); const to = path.join(PROJECT_ROOT, folder); copyDir(from, to); } console.log('šŸŽ‰ [component-lib] Sync complete.\n');