Skip to content

Commit

Permalink
fs.mkdir return strign when success
Browse files Browse the repository at this point in the history
different from documentaion
  • Loading branch information
hjyssg committed Dec 13, 2020
1 parent 2225f15 commit 497ab06
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/server/imageMagickHelp.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ img_convert_min_threshold *= 1024 * 1024;


function logFail(filePath, e) {
logger.error("[imageMagickHelp]]", filePath, e);
logger.error("[imageMagickHelp]", filePath, e);
}

global._has_magick_ = true;
Expand Down Expand Up @@ -90,8 +90,8 @@ module.exports.minifyOneFile = async function (filePath) {
//mkdir for output
if (!(await isExist(minifyOutputPath))) {
const mdkirErr = await pfs.mkdir(minifyOutputPath, { recursive: true });
if (mdkirErr) {
logFail(filePath, "cannot create output folder");
if (mdkirErr instanceof Error) {
logFail(minifyOutputPath, "cannot create output folder");
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function mkdir(path, quiet) {
if (!(await isExist(path))) {
try {
const err = await pfs.mkdir(path, { recursive: true });
if (err) {
if (err instanceof Error) {
throw err;
}
} catch (err) {
Expand Down
4 changes: 3 additions & 1 deletion src/server/routes/moveOrDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ router.post('/api/moveFile', async (req, res) => {
let err;
if (!(await isExist(dest))) {
err = await pfs.mkdir(dest, { recursive: true });
if (err instanceof Error) {
throw "fail to create dest folder";
}
}

if (err) { throw "fail to create dest folder"; }

const cmdStr = isWindows() ? "move" : "mv";
const { stdout, stderr } = await execa(cmdStr, [src, dest]);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/cleanCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function cleanCache(cachePath, config) {
counter = 0
if (!fs.existsSync(cachePath)) {
err = fs.mkdir(cachePath, (err) => {
if (err) {
if (err instanceof Error) {
throw err;
}
});
Expand Down

0 comments on commit 497ab06

Please sign in to comment.