-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
77 lines (73 loc) · 1.98 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Grunt Task Runner
*
* This is simply to facilitate local development. To build any files, use the
* according Metalsmith plugin.
*/
module.exports = function(grunt) {
// Create the Grunt configuration
var config = {
// Execute Metalsmith
exec: {
metalsmith: {
cmd: 'npm run build'
}
},
// Local static web server
connect: {
server: {
options: {
base: 'build',
open: true,
livereload: true
},
},
},
// Watch files and run tasks when changed
watch: {
all: {
files: [
'src/**/*',
'assets/**/*',
'templates/**/*'
],
tasks: ['metalsmith'],
options: {
spawn: false,
interupt: true,
livereload: true
},
},
},
// The Build Control plugin:
// https://www.npmjs.com/package/grunt-build-control
buildcontrol: {
options: {
dir: 'build',
commit: true,
push: true,
message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
},
github: {
options: {
remote: '[email protected]:LoachLabs/MaisonBK.git',
branch: 'live'
}
}
}
};
// Extract any keys from the environmental variables.
if (process.env.GH_TOKEN && process.env.GH_REPO) {
// Update the remote git repository to use the GitHub token.
config.buildcontrol.github.options.remote = "https://" + process.env.GH_TOKEN + "@github.com/" + process.env.GH_REPO + ".git";
}
// Initialize the configuration.
grunt.initConfig(config);
grunt.loadNpmTasks('grunt-build-control');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('metalsmith', ['exec:metalsmith']);
grunt.registerTask('deploy', ['metalsmith', 'buildcontrol:github']);
grunt.registerTask('default', ['metalsmith', 'connect', 'watch']);
};