@gesslar/toolkit 3.30.0 → 3.31.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
CHANGED
|
@@ -462,7 +462,7 @@ export default class FileObject extends FS {
|
|
|
462
462
|
* @returns {Promise<object>} The file contents as a module.
|
|
463
463
|
*/
|
|
464
464
|
async import() {
|
|
465
|
-
const filePath = this.
|
|
465
|
+
const filePath = this.url
|
|
466
466
|
|
|
467
467
|
if(!(await this.exists))
|
|
468
468
|
throw Sass.new(`No such file '${filePath}'`)
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
import path from "node:path"
|
|
12
12
|
import url from "node:url"
|
|
13
13
|
|
|
14
|
-
import Collection from "../../browser/lib/Collection.js"
|
|
15
14
|
import Data from "../../browser/lib/Data.js"
|
|
16
15
|
import Valid from "./Valid.js"
|
|
17
|
-
import
|
|
16
|
+
import Collection from "../../browser/lib/Collection.js"
|
|
18
17
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @import {FileObject} from "./FileObject.js"
|
|
20
|
+
* @import {DirectoryObject} from "./DirectoryObject.js"
|
|
21
|
+
* @import {Sass} from "./Sass.js"
|
|
22
|
+
*/
|
|
21
23
|
|
|
22
24
|
const fdTypes = Object.freeze(["file", "directory"])
|
|
23
25
|
const upperFdTypes = Object.freeze(fdTypes.map(type => type.toUpperCase()))
|
|
@@ -115,7 +117,7 @@ export default class FileSystem {
|
|
|
115
117
|
const relative = path.relative(fromBasePath, to.path)
|
|
116
118
|
|
|
117
119
|
return relative.startsWith("..")
|
|
118
|
-
? to.path
|
|
120
|
+
? path.resolve(to.path)
|
|
119
121
|
: relative
|
|
120
122
|
}
|
|
121
123
|
|
|
@@ -134,7 +136,7 @@ export default class FileSystem {
|
|
|
134
136
|
const relative = path.relative(from, to)
|
|
135
137
|
|
|
136
138
|
return relative.startsWith("..")
|
|
137
|
-
? to
|
|
139
|
+
? path.resolve(to)
|
|
138
140
|
: relative
|
|
139
141
|
}
|
|
140
142
|
|
|
@@ -165,9 +167,13 @@ export default class FileSystem {
|
|
|
165
167
|
const result = path.join(...prefix, ...to)
|
|
166
168
|
|
|
167
169
|
// If original path1 was absolute, ensure result is also absolute
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
if(isAbsolutePath1 && !path.isAbsolute(result)) {
|
|
171
|
+
const root = path.parse(path1).root || path.sep
|
|
172
|
+
|
|
173
|
+
return path.join(root, result)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return result
|
|
171
177
|
}
|
|
172
178
|
|
|
173
179
|
// If no overlap, just join the paths
|
|
@@ -235,7 +241,7 @@ export default class FileSystem {
|
|
|
235
241
|
Valid.type(container, "String", {allowEmpty: false})
|
|
236
242
|
Valid.type(candidate, "String", {allowEmpty: false})
|
|
237
243
|
|
|
238
|
-
const realPath = Data.append(container,
|
|
244
|
+
const realPath = Data.append(container, path.sep) // bookend this mofo
|
|
239
245
|
|
|
240
246
|
return candidate.startsWith(realPath)
|
|
241
247
|
}
|
|
@@ -42,7 +42,7 @@ export default class FileSystem {
|
|
|
42
42
|
* @param {FileObject|DirectoryObject} to - The target file or directory object
|
|
43
43
|
* @returns {string} The relative path from `from` to `to`, or the absolute path if not reachable
|
|
44
44
|
*/
|
|
45
|
-
static relativeOrAbsolute(from:
|
|
45
|
+
static relativeOrAbsolute(from: path | path, to: path | path): string;
|
|
46
46
|
/**
|
|
47
47
|
* Computes the relative path from one file or directory to another.
|
|
48
48
|
*
|
|
@@ -196,8 +196,6 @@ export default class FileSystem {
|
|
|
196
196
|
* @returns {string} The relative path from the source to this instance, or the absolute path if not reachable
|
|
197
197
|
* @throws {Sass} If the parameter is not a FileObject or DirectoryObject
|
|
198
198
|
*/
|
|
199
|
-
relativeTo(fileOrDirectoryObject:
|
|
199
|
+
relativeTo(fileOrDirectoryObject: path | path): string;
|
|
200
200
|
}
|
|
201
|
-
export type FileObject = import("./FileObject.js").default;
|
|
202
|
-
export type DirectoryObject = import("./DirectoryObject.js").default;
|
|
203
201
|
//# sourceMappingURL=FileSystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileSystem.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileSystem.js"],"names":[],"mappings":"AA6BA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;IAsBtB;;;;;;OAMG;IACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;OAQG;IACH,0BALW,MAAM,GACJ,MAAM,CAUlB;IAED;;;;;;;;;;OAUG;IACH,gCAJW,IAAU,GAAC,IAAe,MAC1B,IAAU,GAAC,IAAe,GACxB,MAAM,CAYlB;IAED;;;;;;;;;;OAUG;IACH,oCAJW,MAAM,MACN,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;;OASG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,CA8BlB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAmClB;IAED;;;;;;;;;;;;OAYG;IACH,+BATW,MAAM,aACN,MAAM,GACJ,OAAO,CAcnB;IAED;;;;;;;;;;;;;;OAcG;IACH,iCATW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CAwBvB;IAED;;;;;;;;;;;;;;OAcG;IACH,4BARW,MAAM,MACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,+BAXW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CA+BvB;IAED;;;;;;;OAOG;IAEH;;;;;;;OAOG;IACH,2BAJW,MAAM;;;;cAXH,MAAM;;;;aACN,MAAM;;;;aACN,MAAM;;;;cACN,MAAM;;;;cACN,MAAM;MAenB;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAvVD;;;;;;;;;OASG;IACH,kCAJW,IAAU,GAAC,IAAe,GACxB,MAAM,CAWlB;CAsUF"}
|