feat: 完善一波代码 & 支持win(待测试验证)

This commit is contained in:
volare
2022-12-04 17:53:43 +08:00
parent 93a79f482f
commit 84d749a54d
10 changed files with 164 additions and 30 deletions

4
bin/options/icon.ts vendored
View File

@@ -5,7 +5,7 @@ import { dir } from 'tmp-promise';
import path from 'path';
import fs from 'fs/promises';
import { fileURLToPath } from 'url';
import log from 'loglevel';
import logger from './logger.js';
export async function handleIcon(options: PakeAppOptions, url: string) {
if (options.icon) {
@@ -21,7 +21,7 @@ export async function handleIcon(options: PakeAppOptions, url: string) {
}
export async function inferIcon(name: string, url: string) {
log.info('You have not provided an app icon, use the default icon(can use --icon option to assign an icon)')
logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)')
const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
return path.join(npmDirectory, 'pake-default.icns');
}

22
bin/options/logger.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
import log from 'loglevel';
import chalk from 'chalk';
const logger = {
info(...msg: any[]) {
log.info(...msg.map((m) => chalk.blue.bold(m)));
},
debug(...msg: any[]) {
log.debug(...msg);
},
error(...msg: any[]) {
log.error(...msg.map((m) => chalk.red.bold(m)));
},
warn(...msg: any[]) {
log.info(...msg.map((m) => chalk.yellow.bold(m)));
},
success(...msg: any[]) {
log.info(...msg.map((m) => chalk.green.bold(m)));
}
};
export default logger;