-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: iconifyIntelliSense 支持自定义路径 (#25)
* feat: iconifyIntelliSense 支持自定义路径 * feat: 自定义路径 * perf: 优化代码
- Loading branch information
Showing
11 changed files
with
78 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs' | ||
import { join } from 'node:path' | ||
import { cwd } from 'node:process' | ||
import { injectJsonc } from './utils' | ||
|
||
/** | ||
* vscode `iconify.customCollectionJsonPaths` 配置 | ||
* | ||
* @param dir `.vscode` 的绝对路径 | ||
* @param jsons json 文件路径 | ||
*/ | ||
export async function IconifyIntelliSenseSettings(jsons: string[]): Promise<void> { | ||
const dir = join(cwd(), '.vscode') | ||
export async function IconifyIntelliSenseSettings(dir: string, jsons: string[]): Promise<void> { | ||
// 判断目录是否存在 | ||
if (!existsSync(dir)) { | ||
mkdirSync(dir, { recursive: true }) | ||
} | ||
// 判断文件是否存在 | ||
const settingPath = join(dir, 'settings.json') | ||
|
||
if (!existsSync(settingPath)) { | ||
writeFileSync(settingPath, '{}') | ||
writeFileSync(settingPath, '{}', { encoding: 'utf-8' }) | ||
} | ||
|
||
// 生成配置 | ||
const settingText = readFileSync(settingPath, 'utf-8') | ||
|
||
writeFileSync(settingPath, injectJsonc(settingText, 'iconify.customCollectionJsonPaths', jsons), { | ||
encoding: 'utf-8', | ||
}) | ||
// 写入配置 | ||
const newContent = injectJsonc(settingText, 'iconify.customCollectionJsonPaths', jsons) | ||
writeFileSync(settingPath, newContent, { encoding: 'utf-8' }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters