Рефакторинг

This commit is contained in:
Book Pauk
2019-01-06 13:51:24 +07:00
parent 0ea28c27ad
commit 1c136b3a34
5 changed files with 15 additions and 35 deletions

View File

@@ -1,28 +1,9 @@
const Promise = require('bluebird');
const fs = require('fs');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function statPathSync(path) {
try {
return fs.statSync(path);
} catch (ex) {}
return false;
}
function mkDirIfNotExistsSync(path) {
let exists = statPathSync(path);
if (!exists) {
fs.mkdirSync(path, {recursive: true});
} else if (!exists.isDirectory()) {
throw new Error(`Not a directory: ${path}`);
}
}
module.exports = {
sleep,
statPathSync,
mkDirIfNotExistsSync,
sleep
};