[英]chokidar ignore everything except xml files
關於Chokidar配置,我想設置選項。 我想忽略除xml文件之外的所有內容。
{
"path": "C:/... my path ...",
"options": {
"ignored": "everything except xml files",
"persistent": true
}
}
一個可能的解決方案是
但是有一種方法可以將JSON配置文件的ignored
屬性設置為“忽略.xml文件以外的所有內容”,而不是通過代碼進行設置嗎?
我試圖去這段代碼
{
"path": "C:/...",
"options": {
"ignored": "!**.xml",
"persistent": true
}
}
const chokidar = require('chokidar');
const { path, options } = require('../fileSystemWatcherConfiguration.json');
module.exports = eventEmitter => {
const watcher = chokidar.watch(path, options);
}
但是watcher.on('add', func)
事件會在每個文件擴展名上觸發。
事實證明,這實際上很簡單。
const watcher = chokidar.watch(`${path}/**/*.xml`, options);
通過分析軟件包代碼 ,我們可以看到chokidar
使用內部的anymatch來決定是否應忽略該文件。
挖斗anymatch
使用 micromatch和實例micromatch
我們可以看到 ,我們可以使用!
一開始就否定數學。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.