1.0.3 • Published 2 years ago

@heiwa4126/esm-dirname v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@heiwa4126/esm-dirname (npm-esm-dirname)

This module provides functionality to retrieve the script directory and filename and set the script directory as the current working directory using Node.js’s path and url modules for ECMAScript.

It is the same as CommonJS’s __dirname and __filename. It’s a short code, but I got tired of writing it over and over again so I made it into a package.

Install

npm install @heiwa4126/esm-dirname

Usage

import esmDirname from "@heiwa4126/esm-dirname";
const { __filename, __dirname, setCwdToScriptDir } = esmDirname();

console.log(__dirname); // Script directory
console.log(__filename); // Script filename
setCwdToScriptDir(); // Set script directory as current working directory
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago