Skip to content

Commit

Permalink
fix(bundler): match on Path::extension instead of using `Path::ends…
Browse files Browse the repository at this point in the history
…_with` (#11327)
  • Loading branch information
amrbashir authored Oct 12, 2024
1 parent 2d087ee commit 61bffa4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion crates/tauri-bundler/src/bundle/windows/msi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)?;
Expand Down
27 changes: 25 additions & 2 deletions packages/cli/__tests__/template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
// SPDX-License-Identifier: MIT

import { resolve } from 'node:path'
import { spawnSync } from 'node:child_process'
import {
existsSync,
readFileSync,
writeFileSync,
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 () => {
Expand All @@ -31,6 +40,8 @@ describe('[CLI] @tauri-apps/cli template', () => {
renameSync(outPath, cacheOutPath)
}

const cli = await import('../main.js')

await cli.run([
'init',
'--directory',
Expand Down Expand Up @@ -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 })
}

0 comments on commit 61bffa4

Please sign in to comment.