/
paths-legacy.mjs
42 lines (36 loc) · 1.25 KB
/
paths-legacy.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @file This file is part of the Keywork project.
* @copyright Nirrius, LLC. All rights reserved.
* @author Teffen Ellis, et al.
* @license AGPL-3.0
*
* @remarks Keywork is free software for non-commercial purposes.
* You can be released from the requirements of the license by purchasing a commercial license.
* Buying such a license is mandatory as soon as you develop commercial activities
* involving the Keywork software without disclosing the source code of your own applications.
*
* @see LICENSE.md in the project root for further licensing information.
*/
import * as path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
/**
* The absolute path to the project root.
*/
export const projectRoot = path.dirname(__filename)
/**
* A path builder to the absolute project root.
* @type {(...paths: string[]) => string}
*/
export const projectPath = path.join.bind(null, projectRoot)
export const packagesDirectory = path.join(projectRoot, 'packages')
/**
*
* @param {string} filePath
* @param {string} extension
* @returns {string}
*/
export function changeExtension(filePath, extension) {
const parsedPath = path.parse(filePath)
return parsedPath.dir + path.sep + parsedPath.name + extension
}