UNPKG

magica

Version:

ImageMagick for browser and Node.js, easy setup, high level API and Command Line Interface, including WASM binary for an easy setup.

32 lines 975 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const options_1 = require("../options"); const lsR_1 = require("./lsR"); function rmRf(f, FS, predicate = f => true, removed = []) { if (FS.isDir(FS.stat(f).mode)) { lsR_1.ls(f, FS).some(f => rmRf(f, FS, predicate, removed)); if (predicate(f)) { try { FS.rmdir(f); removed.push(f); } catch (error) { options_1.getOption('debug') && console.log(`Error in rmRf command rmdir ${f}`, error); return true; } } } else if (predicate(f)) { try { FS.unlink(f); removed.push(f); } catch (error) { options_1.getOption('debug') && console.log(`Error in rmRf command unlink ${f}`, error); return true; } } return false; } exports.rmRf = rmRf; //# sourceMappingURL=rmRf.js.map