Skip to content

Commit 5795aaa

Browse files
Run npm verbosely when debug mode is enabled (#340)
* Run npm verbosely when debug mode is enabled When an npm command hangs or misbehaves during preparation, the runner shows nothing that explains where it is stuck. Append --loglevel=silly to the npm install and build commands when WPT_DEBUG is set, matching how debug mode already adds verbosity to the rsync operations. Default behavior is unchanged. Based on the approach in #221 by @rollecode, updated to gate the verbosity behind WPT_DEBUG as suggested in the review discussion. * Move the npm verbosity setup above the checkout comment block Keeps the existing block attached to the perform_operations() call it describes and uses the file's multi-line comment style, as suggested in review. --------- Co-authored-by: Amy Kamala <39748136+kittenkamala@users.noreply.github.com>
1 parent d974e38 commit 5795aaa

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎.env.default‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ export WPT_SSH_PRIVATE_KEY_BASE64=""
6060
# Whether to enable debug Mode.
6161
#
6262
# Enabling debug mode will output verbose logging and details about each part
63-
# of the test runner.
63+
# of the test runner. It also runs npm install and build commands with
64+
# --loglevel=silly during preparation.
6465
#
6566
# 0 = Debug mode off
6667
# 1 = Debug mode on

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export WPT_SSH_OPTIONS=""
241241
export WPT_SSH_PRIVATE_KEY_BASE64=""
242242
243243
# Output logging
244-
# Use 'verbose' to increase verbosity
244+
# Use 'verbose' to increase verbosity; also runs npm with --loglevel=silly
245245
export WPT_DEBUG=""
246246
247247
# Certificate validation
@@ -395,7 +395,7 @@ export WPT_SSH_PRIVATE_KEY_BASE64=""
395395
396396
**Output logging**
397397
398-
Output logging. Use 'verbose' to increase verbosity.
398+
Output logging. Use 'verbose' to increase verbosity. When set, the npm install and build commands during preparation also run with `--loglevel=silly`.
399399
400400
```
401401
export WPT_DEBUG=""

‎prepare.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@
7676
}
7777

7878

79+
/*
80+
* When debug mode is enabled, run npm at its most verbose logging level, so a
81+
* hung or slow npm command shows what it is doing instead of sitting silent.
82+
* The same debug mode adds verbosity to the rsync operations further down.
83+
*/
84+
$npm_verbosity = $runner_vars['WPT_DEBUG'] ? ' --loglevel=silly' : '';
85+
7986
/*
8087
* Checkout and prepare wordpress-develop for testing.
8188
*
@@ -96,7 +103,7 @@
96103
'git clone --depth=1 https://github.com/WordPress/wordpress-develop.git ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ),
97104

98105
// Change directory to the preparation directory, install npm dependencies, and build the project.
99-
'cd ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ) . '; npm install && npm run build',
106+
'cd ' . escapeshellarg( $runner_vars['WPT_PREPARE_DIR'] ) . '; npm install' . $npm_verbosity . ' && npm run build' . $npm_verbosity,
100107

101108
)
102109
);

0 commit comments

Comments
 (0)