oslllo / svg-fixer

Converts SVG Strokes To Fill.
https://docs-oslllo-com.onrender.com/svg-fixer/master
MIT License
213 stars 19 forks source link

Process never ends on error when use promise #98

Closed ghost closed 7 months ago

ghost commented 7 months ago

suppose following code is exist in a file named test.js:

const SVGFixer = require("oslllo-svg-fixer");
const options = {
    showProgressBar: true,
    throwIfDestinationDoesNotExist: false
};
const dirPath = "D:\\not-exist-folder";
SVGFixer(dirPath, dirPath, options)
    .fix()
    .then((result) => {
        console.log("Svg fixed", result);
    })
    .catch((error) => {
        console.log("Failed to fix", error);
    });

When you run the followin code:

node test.js

you will get this error which is correct:

    throw error.invalidPathError("source", source);
    ^

TypeError: source path D:\not-exist-folder does not exist.
    at Object.invalidPathError (D:\svgTestnode_modules\oslllo-svg-fixer\src\error.js:27:10)
    at new Location (D:\svgTestnode_modules\oslllo-svg-fixer\src\location.js:17:17)
    at new SVGFixer (D:\svgTestnode_modules\oslllo-svg-fixer\src\constructor.js:13:19)
    at SVGFixer (D:\svgTestnode_modules\oslllo-svg-fixer\src\constructor.js:10:12)
    at Object.<anonymous> (D:\svgTesttest2.js:7:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)

Node.js v20.11.0

But it will never exist the process and progress will not done.

After the following line this this.teardown(); should called: https://github.com/oslllo/svg-fixer/blob/b7e025a3d923db7607a3bc1af22ec2e3a7baa68a/src/processor.js#L60