server: replace fs callbacks with promises

This commit is contained in:
Jesse Chan
2020-12-09 22:24:28 +08:00
parent 37a94912f4
commit fd971ddcd8
3 changed files with 22 additions and 40 deletions
-17
View File
@@ -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();