Skip to content

Commit 08d05c9

Browse files
committed
fix: monkeypatch util.debuglog() for extended console logging
the old logging functionality of gh-pages was removed in tschaub/gh-pages@380a9ae
1 parent 6a8a3c2 commit 08d05c9

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ In this case, provide **both** `name` and `email` string values to identify the
247247
* `ng deploy --no-silent` – Logging shows extended information.
248248

249249
Logging is in silent mode by default.
250-
In silent mode, log messages are suppressed and error messages are sanitized.
250+
In silent mode, the error messages for git operations are always sanitized.
251+
(The message is always: `'Unspecified error (run without silent option for detail)'`)
251252

252-
The `--no-silent` option enables extended console logging.
253+
The `--no-silent` option enables detailed error messages and extended console logging.
253254
Keep this untouched if the repository URL or other information passed to git commands is sensitive!
254255

255256
> ⚠️ WARNING: This option should be kept as it is if the repository URL or other information passed to Git commands is sensitive and should not be logged (== you have a public build server and you are using the `GH_TOKEN` feature).

docs/README_standalone.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,14 @@ In this case provide both `name` and `email` string values to identify the commi
148148
* `npx angular-cli-ghpages --no-silent` -- Logging shows extended information.
149149

150150
Logging is in silent mode by default.
151-
In silent mode log messages are suppressed and error messages are sanitized.
151+
In silent mode, the error messages for git operations are always sanitized.
152+
(The message is always: `'Unspecified error (run without silent option for detail)'`)
152153

153-
The `--no-silent` option enables extended console logging.
154+
The `--no-silent` option enables detailed error messages and extended console logging.
154155
Keep this untouched if the repository URL or other information passed to git commands is sensitive!
155156

156-
> WARNING: This option should kept like it is if the repository URL or other information passed to git commands is sensitive and should not be logged (== you have a public build server). By default the silent mode is enabled to avoid sensitive data exposure.
157+
> ⚠️ WARNING: This option should be kept as it is if the repository URL or other information passed to Git commands is sensitive and should not be logged (== you have a public build server and you are using the `GH_TOKEN` feature).
158+
> By default the silent mode is enabled to avoid sensitive data exposure.
157159

158160

159161
#### --dir <a name="dir"></a>

src/engine/engine.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Schema } from '../deploy/schema';
66
import { GHPages } from '../interfaces';
77
import { defaults } from './defaults';
88

9-
const ghpages = require('gh-pages');
109

1110
export async function run(
1211
dir: string,
@@ -15,6 +14,9 @@ export async function run(
1514
) {
1615
options = prepareOptions(options, logger);
1716

17+
// this has to occur _after_ the monkeypatch of util.debuglog:
18+
const ghpages = require('gh-pages');
19+
1820
// always clean the cache directory.
1921
// avoids "Error: Remote url mismatch."
2022
if (options.dryRun) {
@@ -23,14 +25,14 @@ export async function run(
2325
ghpages.clean();
2426
}
2527

26-
await checkIfDistFolderExists(dir);
27-
await createNotFoundPage(dir, options, logger);
28-
await createCnameFile(dir, options, logger);
29-
await publishViaGhPages(ghpages, dir, options, logger);
28+
await checkIfDistFolderExists(dir);
29+
await createNotFoundPage(dir, options, logger);
30+
await createCnameFile(dir, options, logger);
31+
await publishViaGhPages(ghpages, dir, options, logger);
3032

31-
logger.info(
32-
'🚀 Successfully published via angular-cli-ghpages! Have a nice day!'
33-
);
33+
logger.info(
34+
'🚀 Successfully published via angular-cli-ghpages! Have a nice day!'
35+
);
3436
}
3537

3638
export function prepareOptions(origOptions: Schema, logger: logging.LoggerApi) {
@@ -41,6 +43,20 @@ export function prepareOptions(origOptions: Schema, logger: logging.LoggerApi) {
4143

4244
if (origOptions.noSilent) {
4345
options.silent = !origOptions.noSilent;
46+
47+
// monkeypatch util.debuglog to get all the extra information
48+
// see https://stackoverflow.com/a/39129886
49+
const util = require('util');
50+
let debuglog = util.debuglog;
51+
util.debuglog = set => {
52+
if (set === 'gh-pages') {
53+
return function() {
54+
let message = util.format.apply(util, arguments);
55+
logger.info(message);
56+
}
57+
}
58+
return debuglog(set);
59+
}
4460
}
4561

4662
if (origOptions.noDotfiles) {
@@ -58,11 +74,6 @@ export function prepareOptions(origOptions: Schema, logger: logging.LoggerApi) {
5874
};
5975
}
6076

61-
// gh-pages internal: forwards messages to logger
62-
options['logger'] = function(message) {
63-
logger.info(message);
64-
};
65-
6677
if (process.env.TRAVIS) {
6778
options.message +=
6879
' -- ' +

0 commit comments

Comments
 (0)