lstat panicks if file doesnt exist

This commit is contained in:
2022-06-08 10:09:14 -05:00
parent 588ee08d10
commit f0c3f7db1a
6 changed files with 14 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { lstatSync, readFileSync } from 'fs'
import { existsSync, lstatSync, readFileSync } from 'fs'
import { BaseUrl, FileUrl, ScriptPath, SupportUrl } from './paths'
import {
UserScriptMeta,
@@ -29,7 +29,7 @@ export default function (name: string): [UserScriptMetaFull, string] {
let metaPath = ScriptPath(name).meta
if (lstatSync(metaPath).isFile()) {
if (existsSync(metaPath) && lstatSync(metaPath).isFile()) {
try {
let args: UserScriptMetaPartial = JSON.parse(
readFileSync(metaPath).toString()