You are browsing as a guest. Sign up (or log in) to start making projects!

4h 0m 45s logged

I just spent four hours doing genuinely the most annoying thing on the planet: building for Windows.

I found a neat little Stack Overflow thread that seemed to do what I wanted it to: write a PowerShell script that could set the wallpaper on Windows machines. Not too shabby, I thought. I could probably ask one of my friends to test on their machine. It wouldn’t take too long, maybe half an hour at max.

Boy, was I wrong.

I forced the poor bloke to install ImageMagick, then sent him a CI build. We gave the program a test run, and I ran into my first real challenge: paths.

Oh my God, I hate Windows paths.

Nothing would work—making folders, writing files, any of that until I replaced every single forward slash with Deno’s fromFileUrl. And being a person with not so great memory, I sent over at least five builds before I fixed every single path in the way. Honourable mentions include:

  • I mistook configPath for cachePath
  • fromFileUrl("C:/..") because that is definitely a file:/// URL
  • path.join(`${imageDir}, ${image.name}`)

Part 2: PowerShell. I thought (:clueless: ) that zx would run on PowerShell out of the box. Nope! It depends (and it actually says this in the README too) that it depends almost exclusively on Bash and Bash escaping. There’s a usePowerShell() command, but I genuinely don’t have the energy right now to figure out the refactors required to make that work—on someone else’s machine.

So I make the guy install Git Bash, and also Deno so I can just send him diffs instead of having to send the Full Deno Runtime™ every time I had a new build. At this point, rainwall-analyze finally works (yay!) and dumps the correct paths to the cache folder. We run rainwall-apply, I find four new cases of paths I did not fix, and I go back into VSCode hell.

Part 3: the actual PowerShell script. Usually, on Linux, I just use Bash’s eval whenever I need to run something enclosed in a string, because zx will automatically quote and escape everything you’ve passed in through a variable. There’s no eval with PowerShell, so I do an insane amount of googling. At this point, I send him a total of twelve diffs just to test to see what the heck is going on. We eventually settled on using Deno.Command instead of zx for this one, running pwsh C:\path\to\script C:\path\to\image. Later, after I logged off for the night (at 2:00! I thought I’d be in bed by 22:00!), I did realize one thing—while we were installing Deno, I saw that they had an install script irm https://deno.land/install.ps1 | iex. I figured a much, much easier way would’ve been to just run 'C\path\to\script' | iex instead, but my brain at that insane hour was not having it.

That’s the whole Windows saga, for now. I still have to adjust the lightness curves a little bit, but other than that, we should be nearing completion. Today, I want to test the script with my macOS friend… provided she wakes up earlier than 21:00. Almost there!

0
4

Comments 0

No comments yet. Be the first!