فهرست منبع

fix(bundler): match on `Path::extension` instead of using `Path::ends_with` (#11327)

Amr Bashir 9 ماه پیش
والد
کامیت
61bffa4feb
2فایلهای تغییر یافته به همراه27 افزوده شده و 3 حذف شده
  1. 2 1
      crates/tauri-bundler/src/bundle/windows/msi/mod.rs
  2. 25 2
      packages/cli/__tests__/template.spec.ts

+ 2 - 1
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)?;

+ 25 - 2
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 })
+}