summaryrefslogtreecommitdiff
path: root/node_modules/node-retrieve-globals/util/getWorkingDirectory.js
blob: 2231341c251b511fbd4c6642ff821829af19ebcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import path from "node:path";
import { pathToFileURL } from "node:url";

function addTrailingSlash(path) {
	if(path.endsWith("/")) {
		return path;
	}
	return path + "/";
}


function getWorkingDirectory() {
	// Trailing slash required
	// `import` and `require` should both be relative to working directory (not this file)
	return addTrailingSlash(pathToFileURL(path.resolve(".")).toString());
}

export { getWorkingDirectory };