mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 01:20:17 +00:00
Exit with 1 when --script <script> fails
We throw an exception if the script fails, so app_main() catches it and exit with code 1 (in this way we can detect the problem running scripts from command line).
This commit is contained in:
parent
783b6f4ad9
commit
7620c05aed
@ -129,7 +129,8 @@ void DefaultCliDelegate::execScript(const std::string& filename)
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
script::StdoutEngineDelegate delegate;
|
||||
AppScripting engine(&delegate);
|
||||
engine.evalFile(filename);
|
||||
if (!engine.evalFile(filename))
|
||||
throw std::runtime_error("Error executing script");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ void Engine::printLastResult()
|
||||
m_printLastResult = true;
|
||||
}
|
||||
|
||||
void Engine::eval(const std::string& jsCode,
|
||||
bool Engine::eval(const std::string& jsCode,
|
||||
const std::string& filename)
|
||||
{
|
||||
bool errFlag = true;
|
||||
@ -429,16 +429,17 @@ void Engine::eval(const std::string& jsCode,
|
||||
js_pop(handle, 1);
|
||||
|
||||
onAfterEval(errFlag);
|
||||
return !errFlag;
|
||||
}
|
||||
|
||||
void Engine::evalFile(const std::string& filename)
|
||||
bool Engine::evalFile(const std::string& filename)
|
||||
{
|
||||
std::stringstream buf;
|
||||
{
|
||||
std::ifstream s(FSTREAM_PATH(filename));
|
||||
buf << s.rdbuf();
|
||||
}
|
||||
eval(buf.str(), filename);
|
||||
return eval(buf.str(), filename);
|
||||
}
|
||||
|
||||
} // namespace script
|
||||
|
@ -141,9 +141,9 @@ namespace script {
|
||||
~Engine();
|
||||
|
||||
void printLastResult();
|
||||
void eval(const std::string& jsCode,
|
||||
bool eval(const std::string& jsCode,
|
||||
const std::string& filename = std::string());
|
||||
void evalFile(const std::string& filename);
|
||||
bool evalFile(const std::string& filename);
|
||||
|
||||
Context& context() { return m_ctx; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user