Skip to content

Instantly share code, notes, and snippets.

@brandongregoryscott
Last active June 13, 2020 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandongregoryscott/4f473d3cb34ed8723ac50a6a191cf862 to your computer and use it in GitHub Desktop.
Save brandongregoryscott/4f473d3cb34ed8723ac50a6a191cf862 to your computer and use it in GitHub Desktop.
An example of a module calling another module.
// -----------------------------------------------------------------------------------------
// #region Imports
// -----------------------------------------------------------------------------------------
const shell = require("shelljs");
const {
restoreDotnetSolution,
solutionPathOrExit,
} = require("./restore-dotnet-solution");
// #endregion Imports
// -----------------------------------------------------------------------------------------
// #region Functions
// -----------------------------------------------------------------------------------------
function buildDotnetSolution() {
// Check for the solution path before continuing. If we cannot find it here, the dotnet
// restore will fail, but we're going to need the path later on anyway.
const solutionPath = solutionPathOrExit();
restoreDotnetSolution();
shell.echo("Running dotnet build on the solution...");
const result = shell.exec(`dotnet build ${solutionPath} --no-restore`);
if (result.code !== 0) {
shell.echo("Error running dotnet build!");
shell.exit(result.code);
}
shell.echo("Dotnet solution built");
}
// #endregion Functions
// -----------------------------------------------------------------------------------------
// #region Exports
// -----------------------------------------------------------------------------------------
const buildDotnetSolutionModule = {
buildDotnetSolution,
};
module.exports = buildDotnetSolutionModule;
// #endregion Exports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment