Some final tweaks to the sd card image script

This commit is contained in:
David Carley
2022-09-09 18:54:34 +00:00
parent 0bcd784bb2
commit 49f00be43c
2 changed files with 64 additions and 46 deletions

View File

@@ -11,7 +11,8 @@ module.exports = {
assertOS,
assertEffectiveRoot,
assertFileExists,
assertInstalled
assertInstalled,
doFinally
};
let signalHandlers = [];
@@ -147,3 +148,14 @@ function assertInstalled(tools) {
`);
}
}
async function doFinally(doHandler, finallyHandler) {
const unregister = registerSignalHandler(finallyHandler);
try {
await doHandler();
} finally {
unregister();
await finallyHandler();
}
}