Skip to content

Instantly share code, notes, and snippets.

@silppuri
Last active December 23, 2015 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silppuri/6674856 to your computer and use it in GitHub Desktop.
Save silppuri/6674856 to your computer and use it in GitHub Desktop.
/*
* Runs pdflatex and bibtex on filechange.
* This assumes you have main.tex
* in the folder where command is run.
*
* Usage: node change-wathcer.js somedir &
*/
'use strict';
var fs = require('fs'),
exec = require('child_process').exec,
dir = process.argv[2],
command = "./compile.sh";
fs.watch(dir, function(event, filename) {
exec(command, function(err, stdout, stderr) {
console.log(stdout);
});
});
#!/bin/bash
pdflatex main.tex
bibtex main.aux
pdflatex main.tex
pdflatex main.tex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment