diff --git a/bin/options/icon.ts b/bin/options/icon.ts index a7c4fd8..6ee54e6 100644 --- a/bin/options/icon.ts +++ b/bin/options/icon.ts @@ -2,6 +2,7 @@ import path from 'path'; import axios from 'axios'; import fsExtra from 'fs-extra'; import chalk from 'chalk'; +import { dir } from 'tmp-promise'; import logger from './logger'; import { npmDirectory } from '@/utils/dir'; @@ -43,8 +44,8 @@ export async function downloadIcon(iconUrl: string) { return null; } - const iconPath = `assets/icon.${fileDetails.ext}`; - await fsExtra.outputFile(`./src-tauri/${iconPath}`, iconData); + const { path: tempPath } = await dir(); + const iconPath = `${tempPath}/icon.${fileDetails.ext}`; await fsExtra.outputFile(iconPath, iconData); spinner.succeed(chalk.green('Icon downloaded successfully!')); return iconPath; diff --git a/dist/cli.js b/dist/cli.js index 4ff51ee..a4169bf 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -13,13 +13,14 @@ import http from 'http'; import { promisify } from 'util'; import updateNotifier from 'update-notifier'; import axios from 'axios'; +import { dir } from 'tmp-promise'; import { fileTypeFromBuffer } from 'file-type'; import psl from 'psl'; import isUrl from 'is-url'; import fs from 'fs'; var name = "pake-cli"; -var version = "2.2.2"; +var version = "2.2.3"; var description = "๐Ÿคฑ๐Ÿป Turn any webpage into a desktop app with Rust. ๐Ÿคฑ๐Ÿป ๅพˆ็ฎ€ๅ•็š„็”จ Rust ๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆๅพˆๅฐ็š„ๆกŒ้ข Appใ€‚"; var engines = { node: ">=16.0.0" @@ -78,6 +79,7 @@ var dependencies = { prompts: "^2.4.2", psl: "^1.9.0", shelljs: "^0.8.5", + "tmp-promise": "^3.0.3", "update-notifier": "^6.0.2" }; var devDependencies = { @@ -819,8 +821,8 @@ async function downloadIcon(iconUrl) { if (!fileDetails) { return null; } - const iconPath = `assets/icon.${fileDetails.ext}`; - await fsExtra.outputFile(`./src-tauri/${iconPath}`, iconData); + const { path: tempPath } = await dir(); + const iconPath = `${tempPath}/icon.${fileDetails.ext}`; await fsExtra.outputFile(iconPath, iconData); spinner.succeed(chalk.green('Icon downloaded successfully!')); return iconPath; diff --git a/package.json b/package.json index 344537a..667add3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pake-cli", - "version": "2.2.2", + "version": "2.2.3", "description": "๐Ÿคฑ๐Ÿป Turn any webpage into a desktop app with Rust. ๐Ÿคฑ๐Ÿป ๅพˆ็ฎ€ๅ•็š„็”จ Rust ๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆๅพˆๅฐ็š„ๆกŒ้ข Appใ€‚", "engines": { "node": ">=16.0.0" @@ -59,6 +59,7 @@ "prompts": "^2.4.2", "psl": "^1.9.0", "shelljs": "^0.8.5", + "tmp-promise": "^3.0.3", "update-notifier": "^6.0.2" }, "devDependencies": {