magica
Version:
ImageMagick for browser and Node.js, easy setup, high level API and Command Line Interface, including WASM binary for an easy setup.
44 lines • 2.06 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const misc_utils_of_mine_generic_1 = require("misc-utils-of-mine-generic");
const magickLoaded_1 = require("../../imageMagick/magickLoaded");
const lsR_1 = require("../../util/lsR");
class LSHelper {
constructor() {
this.name = 'ls';
}
exec(options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const { FS } = yield magickLoaded_1.magickLoaded;
const { emscriptenNodeFsRoot } = magickLoaded_1.getOptions();
var path = options.path || emscriptenNodeFsRoot;
var files = options.recursive ? lsR_1.listFilesRecursively(path, FS) : lsR_1.ls(path, FS);
var a = misc_utils_of_mine_generic_1.asArray(files).map(f => typeof f === 'string' ? f : f.path);
if (options.stdout) {
a.forEach(s => magickLoaded_1.pushStdout(s));
}
return options.noReturnValue ? [] : a;
});
}
fnCompileTime(options) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.exec(options);
});
}
fnRunTime(options) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.exec(options);
});
}
}
exports.LSHelper = LSHelper;
//# sourceMappingURL=fsHelper.js.map