Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement a target task to specify deployment targets. Update wordpre…

…ss-client helper accordingly. Fixes #4 - CLI flag for config file
  • Loading branch information...
commit 3a10ccc2bd38585ec243bf8fd56b16f115a848b1 1 parent e06e6d6
@jzaefferer jzaefferer authored committed
Showing with 42 additions and 1 deletion.
  1. +28 −0 README.md
  2. +14 −1 tasks/wordpress.js
View
28 README.md
@@ -31,6 +31,33 @@ grunt.initConfig({
});
```
+This works for a single deployment target. If you have multiple targets, you
+can specify url, username and password for each:
+
+```javascript
+grunt.initConfig({
+ wordpress: {
+ dev: {
+ url: "wordpress.dev",
+ username: "admin",
+ password: "admin",
+ },
+ live: {
+ url: "wordpress.com",
+ username: "admin",
+ password: "admin",
+ },
+ _default: "dev",
+ dir: "dist"
+ }
+});
+```
+
+If nothing is specified, the `_default` target is used. Override using the
+target task:
+
+ grunt target:live deploy
+
* `url`: The URL for the WordPress install.
Can be a full URL, e.g., `http://wordpress.dev:123/some/path`
or as short as just the host name.
@@ -38,6 +65,7 @@ grunt.initConfig({
* `username`: WordPress username.
* `password`: WordPress password.
* `dir`: Directory containing posts, taxonomies, and resources (see [Directory Structure](#directory-structure)).
+* `_default`: The default deployment target, optional.
### Directory Structure
View
15 tasks/wordpress.js
@@ -32,9 +32,18 @@ grunt.registerHelper( "wordpress-recurse", function recurse( rootdir, fn, comple
});
});
+function config() {
+ var target = grunt.config( "target" ) || grunt.config( "wordpress._default" ),
+ base = grunt.config( "wordpress" );
+ if ( target ) {
+ return base[ target ];
+ }
+ return base;
+}
+
grunt.registerHelper( "wordpress-client", function() {
if ( !_client ) {
- _client = wordpress.createClient( grunt.config( "wordpress" ) );
+ _client = wordpress.createClient( config() );
}
return _client;
});
@@ -124,6 +133,10 @@ grunt.registerTask( "wordpress-validate", "Validate HTML files for synchronizing
});
});
+grunt.registerTask( "target", "Runtime configuration to choose deployment target", function( target ) {
+ grunt.config.set( "target", target );
+});
+
grunt.registerTask( "wordpress-publish", "wordpress-validate wordpress-sync" );
grunt.registerTask( "wordpress-deploy", "build-wordpress wordpress-publish" );
grunt.registerTask( "deploy", "wordpress-deploy" );
Please sign in to comment.
Something went wrong with that request. Please try again.