Skip to content

Commit b5a259d

Browse files
nazokingmuuki88
authored andcommitted
support negative exit code.
1 parent a12bd4c commit b5a259d

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/main/resources/com/typesafe/sbt/packager/archetypes/bat-template

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
@echo off
1111

1212
if "%@@APP_ENV_NAME@@_HOME%"=="" set "@@APP_ENV_NAME@@_HOME=%~dp0\\.."
13-
set ERROR_CODE=0
1413

1514
set "APP_LIB_DIR=%@@APP_ENV_NAME@@_HOME%\lib\"
1615

@@ -130,12 +129,7 @@ rem Call the application and pass all arguments unchanged.
130129

131130
@endlocal
132131

133-
if ERRORLEVEL 1 goto error
134-
goto end
135-
136-
:error
137-
set ERROR_CODE=1
138132

139133
:end
140134

141-
exit /B %ERROR_CODE%
135+
exit /B %ERRORLEVEL%

src/sbt-test/windows/test-bat-template/build.sbt

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ TaskKey[Unit]("check-script") <<= (stagingDirectory in Universal, name, streams)
9696
// include space and double-quote is failed...
9797
// can't success include double-quote. arguments pass from Process(Seq("-Da=xx\"yy", "aa\"bb")) is parsed (%1="-Da", %2="xx\"yy aa\"bb") by cmd.exe ...
9898
//checkOutput(0, "arg #0 is [xx\"yy]\nproperty(test.hoge) is [aa\"bb]\nvmarg #0 is [-Dtest.hoge=aa\"bb]\nSUCCESS!", "-Dtest.hoge=aa\"bb", "xx\"yy")
99-
checkOutputEnv(Map("return-code-1"->"true"), 1, "arg #0 is [RC1]\nFAILURE!", "RC1")
99+
checkOutputEnv(Map("return-code"->"1"), 1, "arg #0 is [RC1]\nFAILURE!", "RC1")
100+
checkOutputEnv(Map("return-code"->"2"), 2, "arg #0 is [RC2]\nFAILURE!", "RC2")
101+
checkOutputEnv(Map("return-code"->"-1"), -1, "arg #0 is [RC-1]\nFAILURE!", "RC-1")
100102
assert(fails.toString == "", fails.toString)
101103
}

src/sbt-test/windows/test-bat-template/src/main/scala/test/Test.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ object Test extends App {
1111
println("vmarg #" + i + " is [" + x + "]")
1212
}
1313
}
14-
if(System.getenv("return-code-1") == "true"){
14+
if(System.getenv("return-code") != null){
1515
println("FAILURE!")
16-
System.exit(1)
16+
System.exit(System.getenv("return-code").toInt)
1717
} else {
1818
println("SUCCESS!")
1919
System.exit(0)

0 commit comments

Comments
 (0)