Comparing version 1.0.0 to 1.0.1
@@ -7,9 +7,9 @@ import fs, {promises as fsAsync} from 'node:fs' | ||
const url = new URL(file, base) | ||
const text = await fsAsync.readFile(url, 'utf8') | ||
return JSON.parse(text) | ||
const buffer = await fsAsync.readFile(url) | ||
return JSON.parse(buffer) | ||
}, | ||
loadSync(file) { | ||
const url = new URL(file, base) | ||
const text = fs.readFileSync(url, 'utf8') | ||
return JSON.parse(text) | ||
const buffer = fs.readFileSync(url) | ||
return JSON.parse(buffer) | ||
}, | ||
@@ -16,0 +16,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import url from 'node:url' | ||
import {fileURLToPath} from 'node:url' | ||
import path from 'node:path' | ||
@@ -9,12 +9,9 @@ import {createRequire} from 'node:module' | ||
get filename() { | ||
return url.fileURLToPath(importMeta.url) | ||
return fileURLToPath(importMeta.url) | ||
}, | ||
get __filename() { | ||
return this.filename | ||
}, | ||
get dirname() { | ||
return path.dirname(this.filename) | ||
}, | ||
get __dirname() { | ||
return this.dirname | ||
get require() { | ||
return createRequire(importMeta.url) | ||
}, | ||
@@ -24,5 +21,9 @@ get json() { | ||
}, | ||
get require() { | ||
return createRequire(importMeta.url) | ||
// Aliases | ||
get __filename() { | ||
return this.filename | ||
}, | ||
get __dirname() { | ||
return this.dirname | ||
}, | ||
} | ||
@@ -29,0 +30,0 @@ } |
{ | ||
"name": "esm-utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Utilities you need when migrating to ESModule.", | ||
@@ -60,3 +60,3 @@ "homepage": "https://github.com/fisker/esm-utils#readme", | ||
"devDependencies": { | ||
"@commitlint/cli": "12.1.1", | ||
"@commitlint/cli": "12.1.3", | ||
"@fisker/commitlint-config": "1.3.4", | ||
@@ -63,0 +63,0 @@ "@fisker/eslint-config": "6.0.1", |
@@ -16,3 +16,3 @@ # esm-utils | ||
const {dirname, filename, json} = createEsmUtils(import.meta) | ||
const {dirname, filename, require} = createEsmUtils(import.meta) | ||
``` | ||
@@ -19,0 +19,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5707
45