UNPKG

pascal-utils

Version:

Utility functions for compilation of simple pascal programs, with the Free Pascal compiler, in Node.js.

27 lines 1.08 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = __importDefault(require("child_process")); const compilationFailedError_1 = __importDefault(require("./errors/compilationFailedError")); /** * Compiles a Pascal source file. * @category Compilation * @param {string} inputFile - Source file to compile. * @param {string} outputFile - Output file name (or path). * @returns {Promise<{file: string}>} * @throws {@link CompilationFailedError} if compilation fails. */ function compile(inputFile, outputFile) { return new Promise((resolve, reject) => { child_process_1.default.exec(`fpc "${inputFile}" -o"${outputFile}"`, (error) => { if (error) { reject(new compilationFailedError_1.default(inputFile)); } resolve({ file: inputFile }); }); }); } exports.default = compile; //# sourceMappingURL=compile.js.map