Last active
August 15, 2022 14:27
-
-
Save ozgurg/c844c88324a8c6063fabf23ad92127ff to your computer and use it in GitHub Desktop.
Node.js type="module" path and fs helper. Put the file in the root folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fileURLToPath } from "url"; | |
import { dirname, join } from "path"; | |
import { createReadStream, createWriteStream, existsSync, readFileSync, unlinkSync } from "fs"; | |
const __filename = fileURLToPath(import.meta.url); | |
const __dirname = dirname(__filename); | |
const io = Object.freeze({ | |
join, | |
existsSync, | |
unlinkSync, | |
createReadStream, | |
createWriteStream, | |
readFileSync, | |
path: args => join(__dirname, args) | |
}); | |
export default io; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment