@gesslar/toolkit 2.5.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/CappedDirectoryObject.js +69 -0
- package/src/lib/DirectoryObject.js +42 -1
- package/src/lib/FS.js +21 -1
- package/src/lib/FileObject.js +18 -18
- package/src/types/lib/CappedDirectoryObject.d.ts +6 -0
- package/src/types/lib/CappedDirectoryObject.d.ts.map +1 -1
- package/src/types/lib/DirectoryObject.d.ts +15 -0
- package/src/types/lib/DirectoryObject.d.ts.map +1 -1
- package/src/types/lib/FS.d.ts +11 -0
- package/src/types/lib/FS.d.ts.map +1 -1
- package/src/types/lib/FileObject.d.ts +4 -4
- package/src/types/lib/FileObject.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -157,6 +157,75 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
157
157
|
return true
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Returns the parent directory of this capped directory.
|
|
162
|
+
* Returns null only if this directory is at the cap (the "root" of the capped tree).
|
|
163
|
+
*
|
|
164
|
+
* Note: The returned parent is a plain DirectoryObject (not capped).
|
|
165
|
+
* Use getDirectory() for creating capped subdirectories.
|
|
166
|
+
*
|
|
167
|
+
* @returns {DirectoryObject|null} Parent directory or null if at cap root
|
|
168
|
+
* @example
|
|
169
|
+
* const capped = new TempDirectoryObject("myapp")
|
|
170
|
+
* const subdir = capped.getDirectory("data")
|
|
171
|
+
* console.log(subdir.parent.path) // Returns parent DirectoryObject
|
|
172
|
+
* console.log(capped.parent) // null (at cap root)
|
|
173
|
+
*/
|
|
174
|
+
get parent() {
|
|
175
|
+
const capResolved = path.resolve(this.#cap)
|
|
176
|
+
|
|
177
|
+
// If we're at the cap, return null (cap is the "root")
|
|
178
|
+
if(this.path === capResolved) {
|
|
179
|
+
return null
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Otherwise return the parent (plain DirectoryObject, not capped)
|
|
183
|
+
return super.parent
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Generator that walks up the directory tree, stopping at the cap.
|
|
188
|
+
* Yields parent directories from current up to (and including) the cap root.
|
|
189
|
+
*
|
|
190
|
+
* @returns {Generator<DirectoryObject>} Generator yielding parent DirectoryObject instances
|
|
191
|
+
* @example
|
|
192
|
+
* const capped = new TempDirectoryObject("myapp")
|
|
193
|
+
* const deep = capped.getDirectory("data").getDirectory("files")
|
|
194
|
+
* for(const parent of deep.walkUp) {
|
|
195
|
+
* console.log(parent.path)
|
|
196
|
+
* // .../myapp-ABC123/data/files
|
|
197
|
+
* // .../myapp-ABC123/data
|
|
198
|
+
* // .../myapp-ABC123 (stops at cap)
|
|
199
|
+
* }
|
|
200
|
+
*/
|
|
201
|
+
*#walkUpCapped() {
|
|
202
|
+
const capResolved = path.resolve(this.#cap)
|
|
203
|
+
|
|
204
|
+
// Use super.walkUp but stop when we would go beyond the cap
|
|
205
|
+
for(const dir of super.walkUp) {
|
|
206
|
+
// Don't yield anything beyond the cap
|
|
207
|
+
if(!dir.path.startsWith(capResolved)) {
|
|
208
|
+
break
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
yield dir
|
|
212
|
+
|
|
213
|
+
// Stop after yielding the cap
|
|
214
|
+
if(dir.path === capResolved) {
|
|
215
|
+
break
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Returns a generator that walks up to the cap.
|
|
222
|
+
*
|
|
223
|
+
* @returns {Generator<DirectoryObject>} Generator yielding parent directories
|
|
224
|
+
*/
|
|
225
|
+
get walkUp() {
|
|
226
|
+
return this.#walkUpCapped()
|
|
227
|
+
}
|
|
228
|
+
|
|
160
229
|
/**
|
|
161
230
|
* Creates a new CappedDirectoryObject by extending this directory's path.
|
|
162
231
|
*
|
|
@@ -37,6 +37,7 @@ import Sass from "./Sass.js"
|
|
|
37
37
|
* @property {boolean} temporary - Whether this is marked as a temporary directory
|
|
38
38
|
* @property {boolean} isFile - Always false (this is a directory)
|
|
39
39
|
* @property {boolean} isDirectory - Always true
|
|
40
|
+
* @property {DirectoryObject|null} parent - The parent directory (null if root)
|
|
40
41
|
* @property {Promise<boolean>} exists - Whether the directory exists (async getter)
|
|
41
42
|
* @property {Generator<DirectoryObject>} walkUp - Generator yielding parent directories up to root
|
|
42
43
|
*
|
|
@@ -89,6 +90,14 @@ export default class DirectoryObject extends FS {
|
|
|
89
90
|
temporary: null,
|
|
90
91
|
})
|
|
91
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Cached parent directory object
|
|
95
|
+
*
|
|
96
|
+
* @type {DirectoryObject|null|undefined}
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
#parent = undefined
|
|
100
|
+
|
|
92
101
|
/**
|
|
93
102
|
* Constructs a DirectoryObject instance.
|
|
94
103
|
*
|
|
@@ -147,7 +156,8 @@ export default class DirectoryObject extends FS {
|
|
|
147
156
|
module: this.module,
|
|
148
157
|
extension: this.extension,
|
|
149
158
|
isFile: this.isFile,
|
|
150
|
-
isDirectory: this.isDirectory
|
|
159
|
+
isDirectory: this.isDirectory,
|
|
160
|
+
parent: this.parent ? this.parent.path : null
|
|
151
161
|
}
|
|
152
162
|
}
|
|
153
163
|
|
|
@@ -253,6 +263,37 @@ export default class DirectoryObject extends FS {
|
|
|
253
263
|
return this.#meta.temporary
|
|
254
264
|
}
|
|
255
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Returns the parent directory of this directory.
|
|
268
|
+
* Returns null if this directory is the root directory.
|
|
269
|
+
* Computed lazily on first access and cached.
|
|
270
|
+
*
|
|
271
|
+
* @returns {DirectoryObject|null} The parent directory or null if root
|
|
272
|
+
* @example
|
|
273
|
+
* const dir = new DirectoryObject('/path/to/directory')
|
|
274
|
+
* console.log(dir.parent.path) // '/path/to'
|
|
275
|
+
*
|
|
276
|
+
* const root = new DirectoryObject('/')
|
|
277
|
+
* console.log(root.parent) // null
|
|
278
|
+
*/
|
|
279
|
+
get parent() {
|
|
280
|
+
// Return cached value if available
|
|
281
|
+
if(this.#parent !== undefined) {
|
|
282
|
+
return this.#parent
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Compute parent directory (null if we're at root)
|
|
286
|
+
const parentPath = path.dirname(this.path)
|
|
287
|
+
const isRoot = parentPath === this.path
|
|
288
|
+
|
|
289
|
+
// Cache and return
|
|
290
|
+
this.#parent = isRoot
|
|
291
|
+
? null
|
|
292
|
+
: new DirectoryObject(parentPath, this.temporary)
|
|
293
|
+
|
|
294
|
+
return this.#parent
|
|
295
|
+
}
|
|
296
|
+
|
|
256
297
|
/**
|
|
257
298
|
* Recursively removes a temporary directory and all its contents.
|
|
258
299
|
*
|
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
|
*
|
|
@@ -129,7 +149,7 @@ export default class FS {
|
|
|
129
149
|
static relativeOrAbsolutePath(from, to) {
|
|
130
150
|
const fromBasePath = from.isDirectory
|
|
131
151
|
? from.path
|
|
132
|
-
: from.
|
|
152
|
+
: from.parent?.path ?? path.dirname(from.path)
|
|
133
153
|
|
|
134
154
|
const relative = path.relative(fromBasePath, to.path)
|
|
135
155
|
|
package/src/lib/FileObject.js
CHANGED
|
@@ -29,7 +29,7 @@ import Valid from "./Valid.js"
|
|
|
29
29
|
* @property {string} extension - The file extension
|
|
30
30
|
* @property {boolean} isFile - Always true for files
|
|
31
31
|
* @property {boolean} isDirectory - Always false for files
|
|
32
|
-
* @property {DirectoryObject}
|
|
32
|
+
* @property {DirectoryObject} parent - The parent directory object
|
|
33
33
|
* @property {Promise<boolean>} exists - Whether the file exists (async)
|
|
34
34
|
*/
|
|
35
35
|
|
|
@@ -58,7 +58,7 @@ export default class FileObject extends FS {
|
|
|
58
58
|
* @property {string|null} extension - The file extension
|
|
59
59
|
* @property {boolean} isFile - Always true
|
|
60
60
|
* @property {boolean} isDirectory - Always false
|
|
61
|
-
* @property {DirectoryObject|null}
|
|
61
|
+
* @property {DirectoryObject|null} parent - The parent directory object
|
|
62
62
|
*/
|
|
63
63
|
#meta = Object.seal({
|
|
64
64
|
supplied: null,
|
|
@@ -69,16 +69,16 @@ export default class FileObject extends FS {
|
|
|
69
69
|
extension: null,
|
|
70
70
|
isFile: true,
|
|
71
71
|
isDirectory: false,
|
|
72
|
-
|
|
72
|
+
parent: null,
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Constructs a FileObject instance.
|
|
77
77
|
*
|
|
78
78
|
* @param {string | FileObject} fileName - The file path or FileObject
|
|
79
|
-
* @param {DirectoryObject|string|null} [
|
|
79
|
+
* @param {DirectoryObject|string|null} [parent] - The parent directory (object or string)
|
|
80
80
|
*/
|
|
81
|
-
constructor(fileName,
|
|
81
|
+
constructor(fileName, parent=null) {
|
|
82
82
|
super()
|
|
83
83
|
|
|
84
84
|
// If passed a FileObject, extract its path
|
|
@@ -93,19 +93,19 @@ export default class FileObject extends FS {
|
|
|
93
93
|
|
|
94
94
|
const {dir,base,ext} = this.#deconstructFilenameToParts(fixedFile)
|
|
95
95
|
|
|
96
|
-
const
|
|
97
|
-
switch(Data.typeOf(
|
|
96
|
+
const parentObject = (() => {
|
|
97
|
+
switch(Data.typeOf(parent)) {
|
|
98
98
|
case "String":
|
|
99
|
-
return new DirectoryObject(
|
|
99
|
+
return new DirectoryObject(parent)
|
|
100
100
|
case "DirectoryObject":
|
|
101
101
|
case "TempDirectoryObject":
|
|
102
|
-
return
|
|
102
|
+
return parent
|
|
103
103
|
default:
|
|
104
104
|
return new DirectoryObject(dir)
|
|
105
105
|
}
|
|
106
106
|
})()
|
|
107
107
|
|
|
108
|
-
const final = FS.resolvePath(
|
|
108
|
+
const final = FS.resolvePath(parentObject.path ?? ".", fixedFile)
|
|
109
109
|
|
|
110
110
|
const resolved = final
|
|
111
111
|
const url = new URL(FS.pathToUri(resolved))
|
|
@@ -116,7 +116,7 @@ export default class FileObject extends FS {
|
|
|
116
116
|
this.#meta.name = base
|
|
117
117
|
this.#meta.extension = ext
|
|
118
118
|
this.#meta.module = path.basename(this.supplied, this.extension)
|
|
119
|
-
this.#meta.
|
|
119
|
+
this.#meta.parent = parentObject
|
|
120
120
|
|
|
121
121
|
Object.freeze(this.#meta)
|
|
122
122
|
}
|
|
@@ -145,7 +145,7 @@ export default class FileObject extends FS {
|
|
|
145
145
|
extension: this.extension,
|
|
146
146
|
isFile: this.isFile,
|
|
147
147
|
isDirectory: this.isDirectory,
|
|
148
|
-
|
|
148
|
+
parent: this.parent ? this.parent.path : null
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -253,8 +253,8 @@ export default class FileObject extends FS {
|
|
|
253
253
|
*
|
|
254
254
|
* @returns {DirectoryObject} The parent directory object
|
|
255
255
|
*/
|
|
256
|
-
get
|
|
257
|
-
return this.#meta.
|
|
256
|
+
get parent() {
|
|
257
|
+
return this.#meta.parent
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
/**
|
|
@@ -411,11 +411,11 @@ export default class FileObject extends FS {
|
|
|
411
411
|
if(!this.url)
|
|
412
412
|
throw Sass.new("No URL in file")
|
|
413
413
|
|
|
414
|
-
if(await this.
|
|
414
|
+
if(await this.parent.exists)
|
|
415
415
|
await fs.writeFile(this.url, content, encoding)
|
|
416
416
|
|
|
417
417
|
else
|
|
418
|
-
throw Sass.new(`Invalid directory, ${this.
|
|
418
|
+
throw Sass.new(`Invalid directory, ${this.parent.url.href}`)
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
/**
|
|
@@ -438,8 +438,8 @@ export default class FileObject extends FS {
|
|
|
438
438
|
if(!this.url)
|
|
439
439
|
throw Sass.new("No URL in file")
|
|
440
440
|
|
|
441
|
-
const exists = await this.
|
|
442
|
-
Valid.assert(exists, `Invalid directory, ${this.
|
|
441
|
+
const exists = await this.parent.exists
|
|
442
|
+
Valid.assert(exists, `Invalid directory, ${this.parent.url.href}`)
|
|
443
443
|
|
|
444
444
|
Valid.assert(Data.isBinary(data), "Data must be binary (ArrayBuffer, TypedArray, Blob, or Buffer)")
|
|
445
445
|
|
|
@@ -38,6 +38,12 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
38
38
|
* @returns {boolean} Always true for CappedDirectoryObject instances
|
|
39
39
|
*/
|
|
40
40
|
get capped(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a generator that walks up to the cap.
|
|
43
|
+
*
|
|
44
|
+
* @returns {Generator<DirectoryObject>} Generator yielding parent directories
|
|
45
|
+
*/
|
|
46
|
+
get walkUp(): Generator<DirectoryObject>;
|
|
41
47
|
/**
|
|
42
48
|
* Creates a new CappedDirectoryObject by extending this directory's path.
|
|
43
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CappedDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/CappedDirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH;IAGE;;;;;;;;;;;;;;;;OAgBG;IACH,kBAXW,MAAM,OAAC,OACP,MAAM,WACN,qBAAqB,OAAC,cACtB,OAAO,EAkFjB;IAqBD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;IACH,sBAVW,MAAM,GACJ,qBAAqB,CA0BjC;;CA6CF;
|
|
1
|
+
{"version":3,"file":"CappedDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/CappedDirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH;IAGE;;;;;;;;;;;;;;;;OAgBG;IACH,kBAXW,MAAM,OAAC,OACP,MAAM,WACN,qBAAqB,OAAC,cACtB,OAAO,EAkFjB;IAqBD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IA8DD;;;;OAIG;IACH,cAFa,SAAS,CAAC,eAAe,CAAC,CAItC;IAED;;;;;;;;;;;;;;OAcG;IACH,sBAVW,MAAM,GACJ,qBAAqB,CA0BjC;;CA6CF;4BApS2B,sBAAsB"}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* @property {boolean} temporary - Whether this is marked as a temporary directory
|
|
22
22
|
* @property {boolean} isFile - Always false (this is a directory)
|
|
23
23
|
* @property {boolean} isDirectory - Always true
|
|
24
|
+
* @property {DirectoryObject|null} parent - The parent directory (null if root)
|
|
24
25
|
* @property {Promise<boolean>} exists - Whether the directory exists (async getter)
|
|
25
26
|
* @property {Generator<DirectoryObject>} walkUp - Generator yielding parent directories up to root
|
|
26
27
|
*
|
|
@@ -124,6 +125,20 @@ export default class DirectoryObject extends FS {
|
|
|
124
125
|
* @returns {boolean} True if this is a temporary directory, false otherwise
|
|
125
126
|
*/
|
|
126
127
|
get temporary(): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the parent directory of this directory.
|
|
130
|
+
* Returns null if this directory is the root directory.
|
|
131
|
+
* Computed lazily on first access and cached.
|
|
132
|
+
*
|
|
133
|
+
* @returns {DirectoryObject|null} The parent directory or null if root
|
|
134
|
+
* @example
|
|
135
|
+
* const dir = new DirectoryObject('/path/to/directory')
|
|
136
|
+
* console.log(dir.parent.path) // '/path/to'
|
|
137
|
+
*
|
|
138
|
+
* const root = new DirectoryObject('/')
|
|
139
|
+
* console.log(root.parent) // null
|
|
140
|
+
*/
|
|
141
|
+
get parent(): DirectoryObject | null;
|
|
127
142
|
/**
|
|
128
143
|
* Recursively removes a temporary directory and all its contents.
|
|
129
144
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"AAgBA
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH;uBAqGe,MAAM;IAlEnB;;;;;OAKG;IACH,yCAFW,OAAO,EA6BjB;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IAWD;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,aALa,KAAK,CAAC,MAAM,CAAC,CAOzB;IAED;;;;OAIG;IACH,iBAFa,OAAO,CAInB;IAED;;;;;;;;;;;;OAYG;IACH,cARa,eAAe,GAAC,IAAI,CAwBhC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,UATa,OAAO,CAAC,IAAI,CAAC,CA0BzB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAiBD;;;;;;;;;;;;;;;OAeG;IACH,WAZW,MAAM,GACJ,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;KAAC,CAAC,CAoCpF;IAED;;;;;;;;;;;;OAYG;IACH,uBARW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAqBzB;IA8BD;;;;;;;;;;;;;;;OAeG;IACH,cAZa,MAAM,CAclB;IAED;;;;;;;;;;;;;;OAcG;IACH,UARa,OAAO,CAAC,IAAI,CAAC,CAkBzB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAM5B;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAO5B;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sBAdW,MAAM,GACJ,eAAe,CAoB3B;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,kBAbW,MAAM,GACJ,UAAU,CAmBtB;;CACF;eAvkBc,SAAS;uBACD,iBAAiB"}
|
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"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @property {string} extension - The file extension
|
|
11
11
|
* @property {boolean} isFile - Always true for files
|
|
12
12
|
* @property {boolean} isDirectory - Always false for files
|
|
13
|
-
* @property {DirectoryObject}
|
|
13
|
+
* @property {DirectoryObject} parent - The parent directory object
|
|
14
14
|
* @property {Promise<boolean>} exists - Whether the file exists (async)
|
|
15
15
|
*/
|
|
16
16
|
export default class FileObject extends FS {
|
|
@@ -28,9 +28,9 @@ export default class FileObject extends FS {
|
|
|
28
28
|
* Constructs a FileObject instance.
|
|
29
29
|
*
|
|
30
30
|
* @param {string | FileObject} fileName - The file path or FileObject
|
|
31
|
-
* @param {DirectoryObject|string|null} [
|
|
31
|
+
* @param {DirectoryObject|string|null} [parent] - The parent directory (object or string)
|
|
32
32
|
*/
|
|
33
|
-
constructor(fileName: string | FileObject,
|
|
33
|
+
constructor(fileName: string | FileObject, parent?: DirectoryObject | string | null);
|
|
34
34
|
/**
|
|
35
35
|
* Returns a JSON representation of the FileObject.
|
|
36
36
|
*
|
|
@@ -106,7 +106,7 @@ export default class FileObject extends FS {
|
|
|
106
106
|
*
|
|
107
107
|
* @returns {DirectoryObject} The parent directory object
|
|
108
108
|
*/
|
|
109
|
-
get
|
|
109
|
+
get parent(): DirectoryObject;
|
|
110
110
|
/**
|
|
111
111
|
* Check if a file can be read. Returns true if the file can be read, false
|
|
112
112
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;GAcG;AAEH;uBAuHe,MAAM;IAtHnB;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,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