Created
July 7, 2017 16:50
Star
You must be signed in to star a gist
Spawn a new task!
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
'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