Skip to content

Instantly share code, notes, and snippets.

@simonespa
Last active December 23, 2018 17:41
Show Gist options
  • Select an option

  • Save simonespa/6bcfc63bb4e6c7fc66b95baccac74f40 to your computer and use it in GitHub Desktop.

Select an option

Save simonespa/6bcfc63bb4e6c7fc66b95baccac74f40 to your computer and use it in GitHub Desktop.
File watcher
#!/usr/bin/env node
const fs = require('fs');
const file = '/path/to/file.json';
fs.watch(file, (eventType, filename) => {
fs.readFile(file, 'utf8', function (err, data) {
if (err) throw err;
process.env.DATA = data;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment