@gesslar/toolkit 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/FS.js +20 -0
- package/src/types/lib/FS.d.ts +11 -0
- package/src/types/lib/FS.d.ts.map +1 -1
package/package.json
CHANGED
package/src/lib/FS.js
CHANGED
|
@@ -30,6 +30,26 @@ export default class FS {
|
|
|
30
30
|
static upperFdTypes = upperFdTypes
|
|
31
31
|
static fdType = fdType
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Compute the relative path from another file or directory to this instance.
|
|
35
|
+
*
|
|
36
|
+
* If the target is outside the source (i.e., the relative path starts with ".."),
|
|
37
|
+
* returns the absolute path to this instance instead.
|
|
38
|
+
*
|
|
39
|
+
* @param {FileObject|DirectoryObject} fileOrDirectoryObject - The source file or directory object
|
|
40
|
+
* @returns {string} The relative path from the source to this instance, or the absolute path if not reachable
|
|
41
|
+
* @throws {Sass} If the parameter is not a FileObject or DirectoryObject
|
|
42
|
+
*/
|
|
43
|
+
relativeTo(fileOrDirectoryObject) {
|
|
44
|
+
Valid.assert(
|
|
45
|
+
typeof fileOrDirectoryObject?.path === "string",
|
|
46
|
+
"fileOrDirectoryObject must be a FileObject or DirectoryObject with a path property",
|
|
47
|
+
1
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
return FS.relativeOrAbsolutePath(fileOrDirectoryObject, this)
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
/**
|
|
34
54
|
* Fix slashes in a path
|
|
35
55
|
*
|
package/src/types/lib/FS.d.ts
CHANGED
|
@@ -71,6 +71,17 @@ export default class FS {
|
|
|
71
71
|
* @returns {string} The resolved path
|
|
72
72
|
*/
|
|
73
73
|
static resolvePath(fromPath: string, toPath: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Compute the relative path from another file or directory to this instance.
|
|
76
|
+
*
|
|
77
|
+
* If the target is outside the source (i.e., the relative path starts with ".."),
|
|
78
|
+
* returns the absolute path to this instance instead.
|
|
79
|
+
*
|
|
80
|
+
* @param {FileObject|DirectoryObject} fileOrDirectoryObject - The source file or directory object
|
|
81
|
+
* @returns {string} The relative path from the source to this instance, or the absolute path if not reachable
|
|
82
|
+
* @throws {Sass} If the parameter is not a FileObject or DirectoryObject
|
|
83
|
+
*/
|
|
84
|
+
relativeTo(fileOrDirectoryObject: FileObject | DirectoryObject): string;
|
|
74
85
|
}
|
|
75
86
|
export type FileObject = import("./FileObject.js").default;
|
|
76
87
|
export type DirectoryObject = import("./DirectoryObject.js").default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../../lib/FS.js"],"names":[],"mappings":"AAwBA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;
|
|
1
|
+
{"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../../lib/FS.js"],"names":[],"mappings":"AAwBA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;IAsBtB;;;;;;OAMG;IACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAUlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;OAQG;IACH,sBALW,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC,GAClB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAmCtC;IAED;;;;;;;;;;OAUG;IACH,oCAJW,UAAU,GAAC,eAAe,MAC1B,UAAU,GAAC,eAAe,GACxB,MAAM,CAYlB;IAED;;;;;;;;OAQG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,CA0BlB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAgClB;IA1MD;;;;;;;;;OASG;IACH,kCAJW,UAAU,GAAC,eAAe,GACxB,MAAM,CAWlB;CAyLF;yBA5Na,OAAO,iBAAiB,EAAE,OAAO;8BACjC,OAAO,sBAAsB,EAAE,OAAO"}
|