Skip to content

Commit

Permalink
feat(nx-monorepo): add disable node warnings option (#417)
Browse files Browse the repository at this point in the history
Additionally disable .npmignore for type-safe-api generated node projects, and force install
pipeline sample to save deleting the env when the interface changes.
  • Loading branch information
cogwirrel committed May 18, 2023
1 parent 251efc5 commit d57fee1
Show file tree
Hide file tree
Showing 12 changed files with 1,078 additions and 719 deletions.
27 changes: 27 additions & 0 deletions packages/nx-monorepo/src/nx-monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ export interface NxMonorepoProjectOptions extends TypeScriptProjectOptions {
* @default undefined
*/
readonly monorepoUpgradeDepsOptions?: MonorepoUpgradeDepsOptions;

/**
* Disable node warnings from being emitted during build tasks
* @default false
*/
readonly disableNodeWarnings?: boolean;
}

/**
Expand Down Expand Up @@ -188,6 +194,12 @@ export class NxMonorepoProject extends TypeScriptProject {
}
case NodePackageManager.YARN2: {
this.package.addEngine("yarn", ">=2");
this.gitignore.addPatterns(
".yarn/*",
".pnp.cjs",
"!.yarn/releases",
"!.yarn/plugins"
);
break;
}
}
Expand Down Expand Up @@ -616,6 +628,11 @@ export class NxMonorepoProject extends TypeScriptProject {
this.updateWorkspace();
this.installNonNodeDependencies();

// Disable node warnings if configured
if (this._options.disableNodeWarnings) {
this.disableNodeWarnings();
}

// Prevent sub NodeProject packages from `postSynthesis` which will cause individual/extraneous installs.
// The workspace package install will handle all the sub NodeProject packages automatically.
const subProjectPackages: NodePackage[] = [];
Expand Down Expand Up @@ -746,6 +763,16 @@ export class NxMonorepoProject extends TypeScriptProject {
});
}
}

/**
* Suppress Node warnings from being presented in the console when running builds.
*/
private disableNodeWarnings() {
this.tasks.addEnvironment("NODE_NO_WARNINGS", "1");
this.subprojects.forEach((subProject) =>
subProject.tasks.addEnvironment("NODE_NO_WARNINGS", "1")
);
}
}

/**
Expand Down
Loading

0 comments on commit d57fee1

Please sign in to comment.