-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d90af6b
commit e61f36a
Showing
3 changed files
with
18 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const fs = require('fs'); | ||
const Path = require('path'); | ||
const { MongoClient, ServerApiVersion } = require('mongodb'); | ||
dbtools = require('./dbtools'); | ||
const dbtools = require('./dbtools'); | ||
const xlsx = require('xlsx'); | ||
const chokidar = require('chokidar'); | ||
const System = require('./system'); | ||
|
@@ -25,15 +25,19 @@ function readInventoryFile(filepath) { | |
} | ||
|
||
|
||
var inventoryWatcher = chokidar.watch(Path.join(__dirname, "Inventory"), {ignored: /^\./, persistent: true}); | ||
var inventoryWatcher = chokidar.watch(Path.join(__dirname, "Inventory"), { | ||
ignored: /(^|[\/\\])\../, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
persistent: true, | ||
awaitWriteFinish: true, | ||
This comment has been minimized.
Sorry, something went wrong.
underdorff18
Author
Owner
|
||
}); | ||
console.log(`Watching directory for changes...` ) | ||
|
||
inventoryWatcher | ||
.on('add', function(filepath) { | ||
dbtools.insertSystem(readInventoryFile(filepath)); | ||
}) | ||
.on('change', function(filepath) { | ||
console.log('File', path, 'has been changed'); | ||
dbtools.updateSystem(readInventoryFile(filepath)); | ||
}) | ||
.on('unlink', function(filepath) { | ||
dbtools.deleteSystem(parseInt(Path.basename(filepath, '.xlsx'))); | ||
|
Ignored filter was not working properly. Updated regex to actually filter dot files. This was required to get the update feature working.