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`) } } }