vscode-fs 0.0.2 → 0.0.3
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/dist/index.cjs +56 -1
- package/dist/index.d.cts +42 -1
- package/dist/index.d.mts +42 -1
- package/dist/index.mjs +56 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -199,7 +199,62 @@ async function createNodeFileSystem() {
|
|
|
199
199
|
copy: (source, target, options) => wrap(async () => {
|
|
200
200
|
const overwrite = options?.overwrite !== false;
|
|
201
201
|
await copyRecursive(source.fsPath, target.fsPath, overwrite);
|
|
202
|
-
})
|
|
202
|
+
}),
|
|
203
|
+
isFile: async (uri) => {
|
|
204
|
+
try {
|
|
205
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
206
|
+
if (type !== FileType.File) return false;
|
|
207
|
+
return {
|
|
208
|
+
type,
|
|
209
|
+
ctime: stats.birthtime.getTime(),
|
|
210
|
+
mtime: stats.mtime.getTime(),
|
|
211
|
+
size: stats.size
|
|
212
|
+
};
|
|
213
|
+
} catch {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
isDirectory: async (uri) => {
|
|
218
|
+
try {
|
|
219
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
220
|
+
if (type !== FileType.Directory) return false;
|
|
221
|
+
return {
|
|
222
|
+
type,
|
|
223
|
+
ctime: stats.birthtime.getTime(),
|
|
224
|
+
mtime: stats.mtime.getTime(),
|
|
225
|
+
size: stats.size
|
|
226
|
+
};
|
|
227
|
+
} catch {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
isSymbolicLink: async (uri) => {
|
|
232
|
+
try {
|
|
233
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
234
|
+
if (type !== FileType.SymbolicLink) return false;
|
|
235
|
+
return {
|
|
236
|
+
type,
|
|
237
|
+
ctime: stats.birthtime.getTime(),
|
|
238
|
+
mtime: stats.mtime.getTime(),
|
|
239
|
+
size: stats.size
|
|
240
|
+
};
|
|
241
|
+
} catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
exists: async (uri) => {
|
|
246
|
+
try {
|
|
247
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
248
|
+
return {
|
|
249
|
+
type,
|
|
250
|
+
ctime: stats.birthtime.getTime(),
|
|
251
|
+
mtime: stats.mtime.getTime(),
|
|
252
|
+
size: stats.size
|
|
253
|
+
};
|
|
254
|
+
} catch {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
203
258
|
};
|
|
204
259
|
}
|
|
205
260
|
|
package/dist/index.d.cts
CHANGED
|
@@ -114,6 +114,38 @@ interface FileSystem {
|
|
|
114
114
|
*/
|
|
115
115
|
overwrite?: boolean;
|
|
116
116
|
}): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Check if a file exists.
|
|
119
|
+
*
|
|
120
|
+
* @param uri The uri of the file.
|
|
121
|
+
* @returns True if the file exists, false otherwise.
|
|
122
|
+
* @throws It will not throw any errors if the file does not exist.
|
|
123
|
+
*/
|
|
124
|
+
isFile(uri: URI): Promise<IsFile | false>;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a directory exists.
|
|
127
|
+
*
|
|
128
|
+
* @param uri The uri of the directory.
|
|
129
|
+
* @returns True if the directory exists, false otherwise.
|
|
130
|
+
* @throws It will not throw any errors if the directory does not exist.
|
|
131
|
+
*/
|
|
132
|
+
isDirectory(uri: URI): Promise<IsDirectory | false>;
|
|
133
|
+
/**
|
|
134
|
+
* Check if a symbolic link exists.
|
|
135
|
+
*
|
|
136
|
+
* @param uri The uri of the symbolic link.
|
|
137
|
+
* @returns True if the symbolic link exists, false otherwise.
|
|
138
|
+
* @throws It will not throw any errors if the symbolic link does not exist.
|
|
139
|
+
*/
|
|
140
|
+
isSymbolicLink(uri: URI): Promise<IsSymbolicLink | false>;
|
|
141
|
+
/**
|
|
142
|
+
* Check if the path is exists.
|
|
143
|
+
*
|
|
144
|
+
* @param uri The uri of the file, directory, or symbolic link.
|
|
145
|
+
* @returns True if the file, directory, or symbolic link exists, false otherwise.
|
|
146
|
+
* @throws It will not throw any errors if the file, directory, or symbolic link does not exist.
|
|
147
|
+
*/
|
|
148
|
+
exists(uri: URI): Promise<FileStat | false>;
|
|
117
149
|
}
|
|
118
150
|
/**
|
|
119
151
|
* The `FileStat`-type represents metadata about a file
|
|
@@ -147,6 +179,15 @@ interface FileStat {
|
|
|
147
179
|
*/
|
|
148
180
|
size: number;
|
|
149
181
|
}
|
|
182
|
+
type IsFile = Omit<FileStat, 'type'> & {
|
|
183
|
+
type: FileType.File;
|
|
184
|
+
};
|
|
185
|
+
type IsDirectory = Omit<FileStat, 'type'> & {
|
|
186
|
+
type: FileType.Directory;
|
|
187
|
+
};
|
|
188
|
+
type IsSymbolicLink = Omit<FileStat, 'type'> & {
|
|
189
|
+
type: FileType.SymbolicLink;
|
|
190
|
+
};
|
|
150
191
|
/**
|
|
151
192
|
* A type that filesystem providers should use to signal errors.
|
|
152
193
|
*
|
|
@@ -185,4 +226,4 @@ declare function toFileSystemError(error: NodeJS.ErrnoException): FileSystemErro
|
|
|
185
226
|
//#region src/node.d.ts
|
|
186
227
|
declare function createNodeFileSystem(): Promise<FileSystem>;
|
|
187
228
|
//#endregion
|
|
188
|
-
export { FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileType, createFileSystemError, createNodeFileSystem, toFileSystemError };
|
|
229
|
+
export { FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileType, IsDirectory, IsFile, IsSymbolicLink, createFileSystemError, createNodeFileSystem, toFileSystemError };
|
package/dist/index.d.mts
CHANGED
|
@@ -114,6 +114,38 @@ interface FileSystem {
|
|
|
114
114
|
*/
|
|
115
115
|
overwrite?: boolean;
|
|
116
116
|
}): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Check if a file exists.
|
|
119
|
+
*
|
|
120
|
+
* @param uri The uri of the file.
|
|
121
|
+
* @returns True if the file exists, false otherwise.
|
|
122
|
+
* @throws It will not throw any errors if the file does not exist.
|
|
123
|
+
*/
|
|
124
|
+
isFile(uri: URI): Promise<IsFile | false>;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a directory exists.
|
|
127
|
+
*
|
|
128
|
+
* @param uri The uri of the directory.
|
|
129
|
+
* @returns True if the directory exists, false otherwise.
|
|
130
|
+
* @throws It will not throw any errors if the directory does not exist.
|
|
131
|
+
*/
|
|
132
|
+
isDirectory(uri: URI): Promise<IsDirectory | false>;
|
|
133
|
+
/**
|
|
134
|
+
* Check if a symbolic link exists.
|
|
135
|
+
*
|
|
136
|
+
* @param uri The uri of the symbolic link.
|
|
137
|
+
* @returns True if the symbolic link exists, false otherwise.
|
|
138
|
+
* @throws It will not throw any errors if the symbolic link does not exist.
|
|
139
|
+
*/
|
|
140
|
+
isSymbolicLink(uri: URI): Promise<IsSymbolicLink | false>;
|
|
141
|
+
/**
|
|
142
|
+
* Check if the path is exists.
|
|
143
|
+
*
|
|
144
|
+
* @param uri The uri of the file, directory, or symbolic link.
|
|
145
|
+
* @returns True if the file, directory, or symbolic link exists, false otherwise.
|
|
146
|
+
* @throws It will not throw any errors if the file, directory, or symbolic link does not exist.
|
|
147
|
+
*/
|
|
148
|
+
exists(uri: URI): Promise<FileStat | false>;
|
|
117
149
|
}
|
|
118
150
|
/**
|
|
119
151
|
* The `FileStat`-type represents metadata about a file
|
|
@@ -147,6 +179,15 @@ interface FileStat {
|
|
|
147
179
|
*/
|
|
148
180
|
size: number;
|
|
149
181
|
}
|
|
182
|
+
type IsFile = Omit<FileStat, 'type'> & {
|
|
183
|
+
type: FileType.File;
|
|
184
|
+
};
|
|
185
|
+
type IsDirectory = Omit<FileStat, 'type'> & {
|
|
186
|
+
type: FileType.Directory;
|
|
187
|
+
};
|
|
188
|
+
type IsSymbolicLink = Omit<FileStat, 'type'> & {
|
|
189
|
+
type: FileType.SymbolicLink;
|
|
190
|
+
};
|
|
150
191
|
/**
|
|
151
192
|
* A type that filesystem providers should use to signal errors.
|
|
152
193
|
*
|
|
@@ -185,4 +226,4 @@ declare function toFileSystemError(error: NodeJS.ErrnoException): FileSystemErro
|
|
|
185
226
|
//#region src/node.d.ts
|
|
186
227
|
declare function createNodeFileSystem(): Promise<FileSystem>;
|
|
187
228
|
//#endregion
|
|
188
|
-
export { FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileType, createFileSystemError, createNodeFileSystem, toFileSystemError };
|
|
229
|
+
export { FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileType, IsDirectory, IsFile, IsSymbolicLink, createFileSystemError, createNodeFileSystem, toFileSystemError };
|
package/dist/index.mjs
CHANGED
|
@@ -198,7 +198,62 @@ async function createNodeFileSystem() {
|
|
|
198
198
|
copy: (source, target, options) => wrap(async () => {
|
|
199
199
|
const overwrite = options?.overwrite !== false;
|
|
200
200
|
await copyRecursive(source.fsPath, target.fsPath, overwrite);
|
|
201
|
-
})
|
|
201
|
+
}),
|
|
202
|
+
isFile: async (uri) => {
|
|
203
|
+
try {
|
|
204
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
205
|
+
if (type !== FileType.File) return false;
|
|
206
|
+
return {
|
|
207
|
+
type,
|
|
208
|
+
ctime: stats.birthtime.getTime(),
|
|
209
|
+
mtime: stats.mtime.getTime(),
|
|
210
|
+
size: stats.size
|
|
211
|
+
};
|
|
212
|
+
} catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
isDirectory: async (uri) => {
|
|
217
|
+
try {
|
|
218
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
219
|
+
if (type !== FileType.Directory) return false;
|
|
220
|
+
return {
|
|
221
|
+
type,
|
|
222
|
+
ctime: stats.birthtime.getTime(),
|
|
223
|
+
mtime: stats.mtime.getTime(),
|
|
224
|
+
size: stats.size
|
|
225
|
+
};
|
|
226
|
+
} catch {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
isSymbolicLink: async (uri) => {
|
|
231
|
+
try {
|
|
232
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
233
|
+
if (type !== FileType.SymbolicLink) return false;
|
|
234
|
+
return {
|
|
235
|
+
type,
|
|
236
|
+
ctime: stats.birthtime.getTime(),
|
|
237
|
+
mtime: stats.mtime.getTime(),
|
|
238
|
+
size: stats.size
|
|
239
|
+
};
|
|
240
|
+
} catch {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
exists: async (uri) => {
|
|
245
|
+
try {
|
|
246
|
+
const { type, stats } = await resolveFileType(uri.fsPath);
|
|
247
|
+
return {
|
|
248
|
+
type,
|
|
249
|
+
ctime: stats.birthtime.getTime(),
|
|
250
|
+
mtime: stats.mtime.getTime(),
|
|
251
|
+
size: stats.size
|
|
252
|
+
};
|
|
253
|
+
} catch {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
202
257
|
};
|
|
203
258
|
}
|
|
204
259
|
|
package/package.json
CHANGED