Skip to content
Browse files

Fixed theme use command

  • Loading branch information...
1 parent 9e6e272 commit 3320b175a0fa58ab64c7e331cf8a2e41a7ea710d @DamonOehlman committed Mar 29, 2012
Showing with 31 additions and 24 deletions.
  1. +23 −24 lib/actions/theme.js
  2. +7 −0 lib/docstar.js
  3. +1 −0 package.json
View
47 lib/actions/theme.js
@@ -1,52 +1,51 @@
-var docstar = require('../docstar'),
+var async = require('async'),
+ docstar = require('../docstar'),
events = require('events'),
debug = require('debug')('docstar'),
+ scaffolder = require('scaffolder'),
path = require('path'),
- util = require('util');
+ util = require('util'),
+ out = require('out');
function ThemeHelper() {
};
-ThemeHelper.prototype.use = function(docstar, scaffolder, extraArgs) {
+ThemeHelper.prototype.use = function(ds, cli, extraArgs) {
var theme = extraArgs[0],
helper = this;
if (! theme) {
- scaffolder.error('No theme specified, could not install');
+ docstar.error('No theme specified, could not install');
}
- debug('copying theme to : ' + path.join(docstar.path, '_theme/' + theme))
- scaffolder.copyAssets(
- 'themes/' + theme,
- function() {
- // now tweak the config
- docstar.tweakConfig({
- theme: theme
- });
- },
- path.join(docstar.path, '_theme/' + theme)
- );
+ debug('copying theme to : ' + path.join(ds.path, '_theme/' + theme));
+
+ async.series([
+ ds.scaffolder.copy.bind(ds.scaffolder, 'themes/' + theme, path.join(ds.path, '_theme/' + theme)),
+ ds.tweakConfig.bind(ds, { theme: theme })
+ ], cli.run.bind(cli, 'quit'));
};
-module.exports = function(opts, callback) {
- var scaffolder = this;
-
- docstar.init(opts, function(err, instance) {
+module.exports = function(input) {
+ var cli = this,
+ extraArgs = (input || '').split(/\s/),
+ action = extraArgs[0] || 'use';
+
+ docstar.init(function(err, instance) {
if (err) {
- scaffolder.out(err);
+ docstar.error(err);
}
else {
// create the config helper
- var helper = new ThemeHelper(),
- action = extraArgs[0];
+ var helper = new ThemeHelper();
// if the config helper supports the action, then call it
if (typeof helper[action] == 'function') {
- helper[action].call(helper, instance, scaffolder, extraArgs.slice(1));
+ helper[action].call(helper, instance, cli, extraArgs.slice(1));
}
else {
- scaffolder.out('Do not know how to \'theme ' + action + '\'');
+ out('Do not know how to \'theme ' + action + '\'');
}
}
});
View
7 lib/docstar.js
@@ -17,6 +17,9 @@ var fs = require('fs'),
function DocStar(docpath) {
this.path = path.resolve(docpath || 'docs');
debug('docpath set to ' + this.path);
+
+ // create the scaffolder
+ this.scaffolder = require('scaffolder')(this.path);
};
DocStar.prototype.getConfigPath = function() {
@@ -68,6 +71,10 @@ DocStar.prototype.writeConfig = function(data, callback) {
});
};
+exports.error = function(err) {
+ out('!{red}: {0}', err);
+};
+
exports.init = function(callback) {
var pattern = '**/' + SPHINX_CONFIG_FILE;
View
1 package.json
@@ -16,6 +16,7 @@
"node": ">= 0.4.x < 0.7.0"
},
"dependencies": {
+ "async": "0.1.x",
"climate": "0.2.x",
"debug": "*",
"scaffolder": "0.4.x",

0 comments on commit 3320b17

Please sign in to comment.
Something went wrong with that request. Please try again.