hdoc-tools 0.17.30 → 0.17.32

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 (3) hide show
  1. package/hdoc-serve.js +13 -4
  2. package/hdoc.js +11 -2
  3. package/package.json +1 -1
package/hdoc-serve.js CHANGED
@@ -39,7 +39,7 @@
39
39
  console.log(' Server Port:', port);
40
40
 
41
41
  if (fs.existsSync(path.join(source_path, 'hdocbook-project.json')) == false) {
42
- console.log("No hdocbook-project.json file found in working folder. Unable to continue.");
42
+ console.error("No hdocbook-project.json file found in working folder. Unable to continue.");
43
43
  return -1;
44
44
  }
45
45
 
@@ -51,7 +51,7 @@
51
51
  try {
52
52
  hdocbook_project = require(hdocbook_project_config_path);
53
53
  } catch (e) {
54
- console.log(`\nFailed to load hdocbook-project.json:\n${e}\n`);
54
+ console.error(`\nFailed to load hdocbook-project.json:\n${e}\n`);
55
55
  process.exit(1);
56
56
  }
57
57
 
@@ -86,7 +86,7 @@
86
86
  try {
87
87
  hdocbook_config = require(hdocbook_path);
88
88
  } catch (e) {
89
- console.log(`\nFailed to load hdocbook.json:\n${e}\n`);
89
+ console.error(`\nFailed to load hdocbook.json:${e}\n`);
90
90
  process.exit(1);
91
91
  }
92
92
 
@@ -195,7 +195,7 @@
195
195
  ps,
196
196
  (err) => {
197
197
  if (err) {
198
- console.log(err); // No such file or any other kind of error
198
+ console.error(err); // No such file or any other kind of error
199
199
  return res.sendStatus(400).send('Unexpected error');
200
200
  }
201
201
  });
@@ -300,6 +300,15 @@
300
300
  return;
301
301
  }
302
302
  } else if (fs.existsSync(file_path)) {
303
+ if (file_path.endsWith('hdocbook.json') || file_path.endsWith('hdocbook_project.json')) {
304
+ try {
305
+ // Read & parse file
306
+ JSON.parse(fs.readFileSync(file_path));
307
+ } catch (e) {
308
+ console.error(`Error parsing hdocbook.json: ${e}`);
309
+
310
+ }
311
+ }
303
312
  send_file(req, res, file_path);
304
313
  return;
305
314
  }
package/hdoc.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  (async function () {
3
3
  'use strict';
4
4
 
@@ -9,6 +9,15 @@
9
9
 
10
10
  const packageFile = path.join(__dirname, 'package.json');
11
11
 
12
+ const { info, error } = console;
13
+ console.info = (arg) => {
14
+ info.call(console, `\x1b[33m${arg}\x1b[0m`);
15
+ };
16
+ console.error = (arg) => {
17
+ error.call(console, `\x1b[31m${arg}\x1b[0m`);
18
+ };
19
+
20
+
12
21
  const getHdocPackageVersion = function (packagePath) {
13
22
  if (fs.existsSync(packagePath)) {
14
23
  try {
@@ -110,7 +119,7 @@
110
119
  const ver = require(path.join(__dirname, 'hdoc-ver.js'));
111
120
  ver.run(source_path);
112
121
  } else {
113
- console.log('Unknown command:', command, '\r\n');
122
+ console.error('Unknown command:', command, '\r\n');
114
123
  console.log('Run hdoc help for information regarding this tool.\r\n');
115
124
  }
116
125
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.17.30",
3
+ "version": "0.17.32",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {