Skip to content

Instantly share code, notes, and snippets.

@jsonberry
Created July 7, 2017 16:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jsonberry/22628365e6301c80bce455650bad65dd to your computer and use it in GitHub Desktop.
Spawn a new task!
'use strict';
/*
* Run the Metalsmith build upon hbs and json changes
* This enables live reloading of template and data changes
*/
const { watch } = require('fs');
const { spawn: run } = require('child_process');
const { resolve, extname } = require('path');
const src = resolve(__dirname, '../src/app');
watch(src, {recursive: true}, (eventType, file) => {
let extension = extname(file);
if (extension === '.hbs' || extension === '.json') {
run('npm', ['run', 'metalsmith'], {stdio: 'inherit'});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment