Skip to content

Commit

Permalink
fix: Illegal operation in linux
Browse files Browse the repository at this point in the history
close #63
  • Loading branch information
liuweiGL committed Feb 27, 2023
1 parent 7c4bb44 commit d299720
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugin/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ export const mkdir = async (dirname: string) => {
}
}

export const ensureDirExist = async (filePath: string) => {
const ext = path.extname(filePath)
const dirname = ext ? path.dirname(filePath) : filePath
export const ensureDirExist = async (filePath: string, strip = false) => {
const dirname = strip ? path.dirname(filePath) : filePath
await mkdir(dirname)
}

Expand All @@ -45,7 +44,7 @@ export const writeFile = async (
filePath: string,
data: string | Uint8Array
) => {
await ensureDirExist(filePath)
await ensureDirExist(filePath, true)
await fs.promises.writeFile(filePath, data)
await fs.promises.chmod(filePath, 0o777)
}
Expand Down

0 comments on commit d299720

Please sign in to comment.