Skip to content

Commit

Permalink
watch file
Browse files Browse the repository at this point in the history
  • Loading branch information
devSarry committed Sep 21, 2019
1 parent daa1f58 commit 7a95ad5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"main": "background.js",
"dependencies": {
"chokidar": "^3.1.1",
"core-js": "^2.6.5",
"python-shell": "^1.0.8",
"vue": "^2.6.10"
Expand Down
11 changes: 11 additions & 0 deletions src/components/Indicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

<script>
const { PythonShell } = require('python-shell');
const chokidar = require('chokidar');
const fs = require("fs");
const pyShellOptions = {
pythonPath: 'venv/bin/python3',
pythonOptions: ['-u'], // get print results in real-time
Expand All @@ -39,6 +42,14 @@
if (err) console.log(err);
console.log('finished');
});
let watcher = chokidar.watch('images/result.txt', {persistent: true});
watcher.on('all', path => {
fs.readFile('images/result.txt','utf-8', (err, data) => {
if (err) throw err;
console.log(data);
this.status = parseInt(data);
});
})
}
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ chokidar@^2.0.2, chokidar@^2.1.8:
optionalDependencies:
fsevents "^1.2.7"

chokidar@^3.0.2:
chokidar@^3.0.2, chokidar@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.1.1.tgz#27e953f3950336efcc455fd03e240c7299062003"
integrity sha512-df4o16uZmMHzVQwECZRHwfguOt5ixpuQVaZHjYMvYisgKhE+JXwcj/Tcr3+3bu/XeOJQ9ycYmzu7Mv8XrGxJDQ==
Expand Down

0 comments on commit 7a95ad5

Please sign in to comment.