mirror of
https://github.com/zoriya/flood.git
synced 2026-06-03 03:12:14 +00:00
server: replace fs callbacks with promises
This commit is contained in:
@@ -53,23 +53,6 @@ export const sanitizePath = (input?: string): string => {
|
||||
return path.resolve(input).replace(controlRe, '');
|
||||
};
|
||||
|
||||
export const createDirectory = (directoryPath: string): Promise<void> => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (directoryPath) {
|
||||
fs.mkdir(directoryPath, {recursive: true}, (error) => {
|
||||
if (error) {
|
||||
console.trace('Error creating directory.', error);
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const getDirectoryList = async (inputPath: string) => {
|
||||
if (typeof inputPath !== 'string') {
|
||||
throw fileNotFoundError();
|
||||
|
||||
Reference in New Issue
Block a user