Skip to content

Commit 026f4b1

Browse files
Krinkletrentmwillis
authored andcommitted
Build: Only require config.json for the "deploy" task
This makes the other tasks also usable locally, given they don't use the wordpress config. In prep for fixing issue #40.
1 parent 2ecc93d commit 026f4b1

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Gruntfile.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ grunt.loadNpmTasks( "grunt-jquery-content" );
99
grunt.loadNpmTasks( "grunt-sri" );
1010

1111
grunt.initConfig( {
12-
wordpress: (function() {
13-
var config = require( "./config" );
14-
config.dir = "dist/wordpress";
15-
return config;
16-
})(),
1712
sri: {
1813
generate: {
1914
src: [
@@ -424,8 +419,22 @@ grunt.registerTask( "ensure-dist-resources", function() {
424419
grunt.file.mkdir( "dist/resources" );
425420
} );
426421

422+
grunt.registerTask( "ensure-wordpress-config", function() {
423+
// This will fail with "Cannot find module" if the file
424+
// does not exist
425+
var config = require( "./config" );
426+
config.dir = "dist/wordpress";
427+
grunt.config.merge( {
428+
wordpress: config
429+
} );
430+
} );
431+
427432
grunt.registerTask( "sri-generate", ["ensure-dist-resources", "sri:generate"] );
433+
434+
// The "grunt deploy" command is automatically invoked on git-commit by the server that
435+
// will deploy the WordPress site.
436+
// Task tree: "deploy" > "wordpress-deploy" > "build-wordpress" > "build".
428437
grunt.registerTask( "build", ["sri-generate", "build-index"] );
429-
grunt.registerTask( "deploy", ["wordpress-deploy", "reload-listings"] );
438+
grunt.registerTask( "deploy", ["ensure-wordpress-config", "wordpress-deploy", "reload-listings"] );
430439

431440
};

0 commit comments

Comments
 (0)