Skip to content

Commit

Permalink
Upgrade chokidar to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
kynatro committed Dec 12, 2024
1 parent 4bba8d3 commit 178dc71
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 60 deletions.
71 changes: 25 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"npm": "10.x"
},
"dependencies": {
"chokidar": "^3.5.3",
"chokidar": "^4.0.1",
"front-matter": "^4.0.2",
"yargs": "^17.3.1"
},
Expand All @@ -36,12 +36,17 @@
},
"eslintConfig": {
"env": {
"commonjs": true,
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": false
},
"sourceType": "module"
}
}
}
32 changes: 20 additions & 12 deletions src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ const { RUNNING_TESTS, WATCHING_FILE_NAME } = require('./constants');
const { APP_ROOT_FOLDER, BASE_FOLDERS, TEAM_FOLDER } = require('./userConfig').getUserConfig();

// Watch location based on user specified APP_ROOT_FOLDER
const watcher = chokidar.watch('**/*.md', { cwd: APP_ROOT_FOLDER });
const watcher = chokidar.watch('.', {
ignored: (file, _stats) => (
_stats && _stats.isFile() && !file.endsWith('.md') ||
_stats && _stats.isFile() && path.basename(file) === 'README.md' ||
path.dirname(file).indexOf('Archive') !== -1
),
awaitWriteFinish: true,
cwd: APP_ROOT_FOLDER
});

const model = {
exitScript,
Expand All @@ -21,10 +29,10 @@ const model = {

/**
* Clean up files
*
*
* Removes the .WATCHING file that houses the PID for the watcher when
* started by the "notepack" bin script.
*
*
* @requires fs
* @requires path
*/
Expand All @@ -41,9 +49,9 @@ function exitScript() {

/**
* Update todos for all team members
*
*
* Iterates through all team members and updates their respective folders
*
*
* @requires notepack-cli/team.getTeamMembers
* @requires notepack-cli/updateTodos.updateTodosForPerson
*/
Expand All @@ -62,9 +70,9 @@ function updateTodosForAll() {

/**
* Update todos for "me"
*
*
* Updates the todos assigned to the project owner
*
*
* @requires notepack-cli/updateTodos.updateTodosForPerson
*/
function updateTodosForMe() {
Expand All @@ -86,12 +94,12 @@ function updateRecentFiles() {

/**
* Monitor change events from chokidar watcher
*
*
* Updates todos for a user or every(one|thing) depending on the file path
* received. If the file path is in a team member's folder, only their todos
* and the project owner's will be updated. If a file path is outside the
* and the project owner's will be updated. If a file path is outside the
* team member folder, everything is updated.
*
*
* @requires path
* @requires notepace/updateTodos.updateTodosForPerson
* @requires notepace/updateTodos.updateTodosForFolders
Expand Down Expand Up @@ -129,8 +137,8 @@ if (!RUNNING_TESTS) {
model.updateTodosForAll();
model.updateRecentFiles();
updateTodos.updateTodosForFolders(BASE_FOLDERS);

console.log('Watching folders...');
}

module.exports = model;
module.exports = model;

0 comments on commit 178dc71

Please sign in to comment.