From 24b3180eb5c543dc2fe45bdef62ca87e2947c0c3 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Fri, 21 Jul 2023 19:28:41 +0200 Subject: [PATCH] build.js recreates build output dir after it has been removed (fixes #62) --- CHANGELOG.md | 1 + build.js | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e90847..c17bf28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Find view: paste ID and press Enter (#55). * Preserve state after switching to another tab (#56). * Find view: ask for confirmation before negligently deleting documents when the user has clicked the '-' button (#58). +* Build script recreates the build output directory after it has been removed (#62). ## [v0.2.2] diff --git a/build.js b/build.js index 39d3664..b8e5081 100755 --- a/build.js +++ b/build.js @@ -1,7 +1,7 @@ #!/usr/bin/env node const { execSync, spawn } = require('child_process'); -const { readFileSync, statSync, rmdirSync } = require('fs'); +const { readFileSync, statSync, rmdirSync, mkdirSync } = require('fs'); // Check that the script is run from the root. @@ -145,6 +145,12 @@ if (missingDependencies.length > 0) { console.log('Cleaning output directory...'); try { rmdirSync('./build/bin'); } catch {} +try { + mkdirSync('./build/bin'); +} +catch (err) { + console.log('Failed to create build output directory!'); +} // Build Rolens. @@ -154,8 +160,25 @@ console.log(); const proc = spawn('wails', [ 'build', '-clean', isWindows ? '-nsis' : '' ]); if (!quiet) { - proc.stdout.on('data', data => process.stdout.write(data)); + const suppressMessages = [ + 'Wails CLI', + 'If Wails is useful', + 'https://github.com/sponsors/leaanthony', + ]; + + proc.stdout.on('data', data => { + for (let i = 0; i < suppressMessages.length; i++) { + if (data.toString().indexOf(suppressMessages[i]) !== -1) { + return; + } + } + process.stdout.write(data); + }); + proc.stderr.on('data', data => process.stderr.write(data)); } -proc.on('exit', code => process.exit(code)); +proc.on('exit', code => { + console.log(); + process.exit(code); +});