UNPKG

gpreview

Version:

Preview Ghost themes locally without a full Ghost installation

41 lines 1.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createFileWatcher = createFileWatcher; const chokidar_1 = __importDefault(require("chokidar")); const path_1 = __importDefault(require("path")); function createFileWatcher(themePath, onChange) { const watcher = chokidar_1.default.watch([ path_1.default.join(themePath, '**/*.hbs'), path_1.default.join(themePath, 'assets/**/*'), path_1.default.join(themePath, 'package.json'), ], { ignored: [ /node_modules/, /\.git/, /\.DS_Store/, ], persistent: true, ignoreInitial: true, }); watcher .on('add', (filePath) => { console.log(`File added: ${path_1.default.relative(themePath, filePath)}`); onChange(); }) .on('change', (filePath) => { console.log(`File changed: ${path_1.default.relative(themePath, filePath)}`); onChange(); }) .on('unlink', (filePath) => { console.log(`File removed: ${path_1.default.relative(themePath, filePath)}`); onChange(); }) .on('error', (error) => { console.error('Watcher error:', error); }); return watcher; } //# sourceMappingURL=watcher.js.map