Last active
August 29, 2015 14:19
-
-
Save gpedro/dbac96c39028e949d68b to your computer and use it in GitHub Desktop.
Awesome TaskRunner for Harmonic Theme Development.
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
var gulp = require('gulp'); | |
var exec = require('child_process').exec; | |
var path = require('path'); | |
var harmonic = require('./harmonic.json'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
var config = { | |
outDir: 'public' | |
}; | |
var themeDir = function(uri) { | |
return path.join(__dirname, 'node_modules', harmonic.theme, uri); | |
}; | |
gulp.task('clean', require('del').bind(null, [config.outDir])); | |
gulp.task('reload', ['build'], function() { | |
reload(); | |
}); | |
gulp.task('serve', ['build'], function () { | |
browserSync({ | |
notify: false, | |
port: 9000, | |
server: { | |
baseDir: [config.outDir] | |
} | |
}); | |
// watch for changes | |
gulp.watch([ | |
'harmonic.json', | |
'src/**/*.md', | |
'resources/*', | |
themeDir('**/*.{html,css,js}') | |
], ['reload']); | |
}); | |
gulp.task('build', ['clean'], function(cb) { | |
exec('harmonic build', function(err) { | |
if (err) { | |
console.error(err); | |
return cb(err); // return error | |
} | |
cb(); // finished task | |
}); | |
}); | |
gulp.task('default', function() { | |
gulp.start('build'); | |
}); |
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
{ | |
"private": true, | |
"dependencies": { | |
"harmonic-theme-default": "^1.1.2" | |
}, | |
"devDependencies": { | |
"browser-sync": "^2.6.4", | |
"del": "^1.1.1", | |
"gulp": "^3.8.11" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment