From 61bffa4feb1baae265f3cb4b98021cf02fabe800 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Sat, 12 Oct 2024 16:31:11 +0300 Subject: [PATCH] fix(bundler): match on `Path::extension` instead of using `Path::ends_with` (#11327) --- .../src/bundle/windows/msi/mod.rs | 3 ++- packages/cli/__tests__/template.spec.ts | 27 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs index 7aa75173e4a5..db28657e2ccc 100644 --- a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs +++ b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs @@ -21,6 +21,7 @@ use regex::Regex; use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeMap, HashMap, HashSet}, + ffi::OsStr, fs::{self, File}, io::Write, path::{Path, PathBuf}, @@ -611,7 +612,7 @@ pub fn build_wix_app_installer( settings .icon_files() .flatten() - .find(|i| i.ends_with(".ico")) + .find(|i| i.extension() == Some(OsStr::new("ico"))) .context("Couldn't find a .ico icon")? }; let icon_path = copy_icon(settings, "icon.ico", &icon_path)?; diff --git a/packages/cli/__tests__/template.spec.ts b/packages/cli/__tests__/template.spec.ts index e7115dbdfe01..02dd599283d7 100644 --- a/packages/cli/__tests__/template.spec.ts +++ b/packages/cli/__tests__/template.spec.ts @@ -3,6 +3,7 @@ // SPDX-License-Identifier: MIT import { resolve } from 'node:path' +import { spawnSync } from 'node:child_process' import { existsSync, readFileSync, @@ -10,8 +11,16 @@ import { rmSync, renameSync } from 'node:fs' -import cli from '../main.js' -import { describe, it } from 'vitest' +import { beforeAll, describe, it } from 'vitest' + +// Build CLI before tests, for local usage only. +// CI builds the CLI on different platforms and architectures +if (!process.env.CI) { + beforeAll(() => { + const cliDir = resolve(__dirname, '..') + exec('pnpm', ['build:debug'], { cwd: cliDir }) + }) +} describe('[CLI] @tauri-apps/cli template', () => { it('init a project and builds it', { timeout: 15 * 60 * 1000 }, async () => { @@ -31,6 +40,8 @@ describe('[CLI] @tauri-apps/cli template', () => { renameSync(outPath, cacheOutPath) } + const cli = await import('../main.js') + await cli.run([ 'init', '--directory', @@ -63,3 +74,15 @@ describe('[CLI] @tauri-apps/cli template', () => { process.chdir(cwd) }) }) + +function exec( + bin: string, + args?: string[], + opts?: { + cwd?: string + } +) { + process.platform === 'win32' + ? spawnSync('cmd', ['/c', bin, ...(args ?? [])], { cwd: opts?.cwd }) + : spawnSync(bin, args, { cwd: opts?.cwd }) +}