Skip to content

Commit 3625edf

Browse files
committed
fix: add better diagnostics output on errors
1 parent bb7d221 commit 3625edf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bulma-css-vars",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "Bulma with CSS variables",
55
"keywords": [
66
"bulma",

lib/src/fs-helper.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ async function mkdir(dirPath: string) {
99
}
1010

1111
export async function writeFile(filePath: string, content: string) {
12+
if (!fsp || !fsp.writeFile) {
13+
throw new Error('[Bulma CSS Vars] requires fs.promises (Node.js v12 or higher)')
14+
}
1215
const dir = path.dirname(filePath)
1316
if (!(await exists(dir))) {
1417
await mkdir(dir)
@@ -17,6 +20,9 @@ export async function writeFile(filePath: string, content: string) {
1720
}
1821

1922
export async function exists(filePath: string): Promise<boolean> {
23+
if (!fsp || !fsp.access) {
24+
throw new Error('[Bulma CSS Vars] requires fs.promises (Node.js v12 or higher)')
25+
}
2026
try {
2127
await fsp.access(filePath)
2228
return true
@@ -26,6 +32,9 @@ export async function exists(filePath: string): Promise<boolean> {
2632
}
2733

2834
export async function fileStartsWith(filePath: string, start: string): Promise<boolean> {
35+
if (!fsp || !fsp.readFile) {
36+
throw new Error('[Bulma CSS Vars] requires fs.promises (Node.js v12 or higher)')
37+
}
2938
try {
3039
const content = (await fsp.readFile(filePath)).toString()
3140
return content.startsWith(start)

0 commit comments

Comments
 (0)