Skip to content

Commit dd3523a

Browse files
committed
fix: add htm file no exists tips
1 parent b2cb29f commit dd3523a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/extension.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ const disableMessage = 'Gradient ' + disableName + 'd. ' + enableCommonMessage
4747
* @returns
4848
*/
4949
function getResetContent() {
50+
if (!fs.existsSync(htmlFile)) {
51+
showMessage('Gradient Theme is not supported on this platform.')
52+
return ''
53+
}
54+
5055
const html = fs.readFileSync(htmlFile, 'utf-8')
5156
const regex = new RegExp(
5257
`<style[^>]*${config.tagAttr}[^>]*>.*?</style>|<script[^>]*${config.tagAttr}[^>]*>.*?</script>`,
@@ -60,6 +65,11 @@ function getResetContent() {
6065
* 重置html文件,用于删除所有插件插入的style和script
6166
*/
6267
function reset() {
68+
if (!fs.existsSync(htmlFile)) {
69+
showMessage('Gradient Theme is not supported on this platform.')
70+
return ''
71+
}
72+
6373
const output = getResetContent()
6474
fs.writeFileSync(htmlFile, output, 'utf-8')
6575
}
@@ -68,6 +78,11 @@ function reset() {
6878
* enable命令后,启动主题样式插入逻辑
6979
*/
7080
function install() {
81+
if (!fs.existsSync(htmlFile)) {
82+
showMessage('Gradient Theme is not supported on this platform.')
83+
return ''
84+
}
85+
7186
const themeConfig = vscode.workspace.getConfiguration('gradientTheme')
7287
const css = themeConfig ? themeConfig.css : []
7388
const customCssOutHtml = css

0 commit comments

Comments
 (0)