zhangdocs 1.1.34 → 1.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/init.js +31 -10
  2. package/package.json +2 -2
package/lib/init.js CHANGED
@@ -91,10 +91,8 @@ function runTask(commander) {
91
91
  if (!/\/$/.test(todir)) todir = todir + '/';
92
92
 
93
93
  // 记录皮肤名字
94
- if (answers.zhangdocstheme) {
95
- answers.zhangdocs.theme = answers.zhangdocstheme;
96
- delete answers.zhangdocstheme;
97
- }
94
+ answers.zhangdocs.theme = answers.theme;
95
+ delete answers.theme;
98
96
 
99
97
  //需要生成的md文件路径
100
98
  if (commander.init) {
@@ -148,19 +146,42 @@ function runTask(commander) {
148
146
  var todir = default_package.zhangdocs.todir ? default_package.zhangdocs.todir : __dirname;
149
147
 
150
148
  log()
151
- log(color.green('Initialization is successful! Please run "zhangdocs build" command!'));
149
+ log(color.green('Initialization is successful! Please run "doc build" command!'));
152
150
  log()
153
151
 
154
- })
152
+ }).catch(function (err) {
153
+ if (err && err.isTtyError) {
154
+ log(color.red('\nInitialization cancelled.\n'));
155
+ return;
156
+ }
157
+ log(color.red('\nInitialization failed!'));
158
+ if (err && err.message) {
159
+ log(color.red(err.message));
160
+ }
161
+ if (err && err.stack) {
162
+ log(color.red(err.stack));
163
+ }
164
+ log();
165
+ });
155
166
  return;
156
167
  }
157
168
 
158
169
  function init(commander) {
159
- if (fs.existsSync(template + '/theme/default/')) {
160
- runTask(commander);
161
- } else {
162
- log(color.red("Initialization failed!"));
170
+ var themeDir = path.join(template, 'theme');
171
+ if (!fs.existsSync(themeDir)) {
172
+ log(color.red('\nInitialization failed!'));
173
+ log(color.red('Theme directory not found: ' + themeDir));
174
+ log(color.red('Reinstall doc: npm install -g zhangdocs\n'));
175
+ return;
176
+ }
177
+ var themes = theme.themeList();
178
+ if (!themes || themes.length === 0) {
179
+ log(color.red('\nInitialization failed!'));
180
+ log(color.red('No themes found in: ' + themeDir));
181
+ log(color.red('Expected at least one theme folder (e.g. handbook).\n'));
182
+ return;
163
183
  }
184
+ runTask(commander);
164
185
  }
165
186
 
166
187
  module.exports = init;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zhangdocs",
3
- "version": "1.1.34",
3
+ "version": "1.1.35",
4
4
  "description": "Simple document generation tool. Dependence Node.js run.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  "underscore": "^1.8.3"
40
40
  },
41
41
  "zhangdocs": {
42
- "theme": "default",
42
+ "theme": "handbook",
43
43
  "md": [
44
44
  "README.md"
45
45
  ]