Skip to content

Commit

Permalink
Merge pull request microsoft#4022 from zecheng01/feature/rush-event-h…
Browse files Browse the repository at this point in the history
…ook-output

[rush-lib] enable event hook scripts output by default
  • Loading branch information
iclanton authored Mar 24, 2023
2 parents 2e96933 + 86166ab commit 441ea30
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Add experiment `printEventHooksOutputToConsole` to allow printing outputs from event hooks to the console.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
7 changes: 6 additions & 1 deletion common/config/rush/experiments.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@
* If true, perform a clean install after when running `rush install` or `rush update` if the
* `.npmrc` file has changed since the last install.
*/
// "cleanInstallAfterNpmrcChanges": true
// "cleanInstallAfterNpmrcChanges": true,

/**
* If true, print the outputs of shell commands defined in event hooks to the console.
*/
// "printEventHooksOutputToConsole": true
}
1 change: 1 addition & 0 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export interface IExperimentsJson {
noChmodFieldInTarHeaderNormalization?: boolean;
omitImportersFromPreventManualShrinkwrapChanges?: boolean;
phasedCommands?: boolean;
printEventHooksOutputToConsole?: boolean;
usePnpmFrozenLockfileForRushInstall?: boolean;
usePnpmPreferFrozenLockfileForRushUpdate?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@
* If true, perform a clean install after when running `rush install` or `rush update` if the
* `.npmrc` file has changed since the last install.
*/
/*[LINE "HYPOTHETICAL"]*/ "cleanInstallAfterNpmrcChanges": true
/*[LINE "HYPOTHETICAL"]*/ "cleanInstallAfterNpmrcChanges": true,

/**
* If true, print the outputs of shell commands defined in event hooks to the console.
*/
/*[LINE "HYPOTHETICAL"]*/ "printEventHooksOutputToConsole": true
}
5 changes: 5 additions & 0 deletions libraries/rush-lib/src/api/ExperimentsConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export interface IExperimentsJson {
* `.npmrc` file has changed since the last install.
*/
cleanInstallAfterNpmrcChanges?: boolean;

/**
* If true, print the outputs of shell commands defined in event hooks to the console.
*/
printEventHooksOutputToConsole?: boolean;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion libraries/rush-lib/src/logic/EventHooksManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ export class EventHooksManager {

const stopwatch: Stopwatch = Stopwatch.start();
console.log('\n' + colors.green(`Executing event hooks for ${Event[event]}`));

const printEventHooksOutputToConsole: boolean | undefined =
isDebug ||
this._rushConfiguration.experimentsConfiguration.configuration.printEventHooksOutputToConsole;
scripts.forEach((script) => {
try {
Utilities.executeLifecycleCommand(script, {
rushConfiguration: this._rushConfiguration,
workingDirectory: this._rushConfiguration.rushJsonFolder,
initCwd: this._commonTempFolder,
handleOutput: !isDebug,
handleOutput: !printEventHooksOutputToConsole,
environmentPathOptions: {
includeRepoBin: true
}
Expand Down
4 changes: 4 additions & 0 deletions libraries/rush-lib/src/schemas/experiments.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"cleanInstallAfterNpmrcChanges": {
"description": "If true, perform a clean install after when running `rush install` or `rush update` if the `.npmrc` file has changed since the last install.",
"type": "boolean"
},
"printEventHooksOutputToConsole": {
"description": "If true, print the outputs of shell commands defined in event hooks to the console.",
"type": "boolean"
}
},
"additionalProperties": false
Expand Down

0 comments on commit 441ea30

Please sign in to comment.