From 54d97a0f7d5d5ca946404976db00d27386b09254 Mon Sep 17 00:00:00 2001 From: AraHaan Date: Thu, 17 Jun 2021 15:44:09 -0400 Subject: [PATCH] Fix erroring out when solution file is not passed in explicitly. Solution file should have been optional. Also now throws when commands executed return non-0 exit result. --- .gitignore | 1 + index.js | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index e43b0f9..f32e31a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.idea/ .DS_Store diff --git a/index.js b/index.js index e19f199..3c08694 100644 --- a/index.js +++ b/index.js @@ -21,26 +21,25 @@ class Action { return spawnSync(TOOL, ARGS, options) } - _executeInProcess(cmd) { - this._executeCommand(cmd, { encoding: "utf-8", stdio: [process.stdin, process.stdout, process.stderr] }) + _executeInProcess(cmd, errmsg) { + if (this._executeCommand(cmd, { encoding: "utf-8", stdio: [process.stdin, process.stdout, process.stderr] }).status > 0) + { + this._printErrorAndExit(errmsg) + } } run() { - if (!this.solutionFile || !fs.existsSync(this.solutionFile)) { - this._printErrorAndExit("solution file not found") - } - - this._executeInProcess(`dotnet restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`) - this._executeInProcess(`dotnet build -c Release --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`) + this._executeInProcess(`dotnet restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `restore failed`) + this._executeInProcess(`dotnet build -c Release --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `build failed`) if (this.test) { - this._executeInProcess(`dotnet test -c Release --no-build --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`) + this._executeInProcess(`dotnet test -c Release --no-build --no-restore${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `testing failed`) } if (this.pack) { console.log(`Note: To package symbol packages as well as normal packages specify these msbuild properties inside of the project's csproj file or to an Directory.Build.props file that is automatically imported by the .NET SDK:`) console.log(`https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg#creating-a-symbol-package`) console.log(`setting these will be honored when calling dotnet pack and dotnet nugget push.`) - this._executeInProcess(`dotnet pack --no-build --no-restore -c Release${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`) + this._executeInProcess(`dotnet pack --no-build --no-restore -c Release${this.solutionFile === "" ? this.solutionFile : ` ${this.solutionFile}`}`, `packing failed`) } } }