https://github.com/synthetic-borealis/pascal-utils.js
Detect Free Pascal and compile Pascal programs from Node.js.
https://github.com/synthetic-borealis/pascal-utils.js
javascript nodejs pascal testing-tools
Last synced: 10 months ago
JSON representation
Detect Free Pascal and compile Pascal programs from Node.js.
- Host: GitHub
- URL: https://github.com/synthetic-borealis/pascal-utils.js
- Owner: synthetic-borealis
- License: mit
- Created: 2022-08-25T08:54:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-03T16:20:38.000Z (over 2 years ago)
- Last Synced: 2025-01-31T11:50:38.517Z (11 months ago)
- Topics: javascript, nodejs, pascal, testing-tools
- Language: TypeScript
- Homepage:
- Size: 728 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Pascal Utils

[](https://badge.fury.io/js/pascal-utils)

[](https://codecov.io/gh/synthetic-borealis/pascal-utils.js)
Utility functions for compilation of simple pascal programs with the Free Pascal compiler in
Node.js.
## Contents
1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)
1. [Compiler Detection](#compiler-detection)
2. [Compilation](#compilation)
4. [Examples](#examples)
## Requirements
* The Free Pascal compiler.
* Node.js v16.x or above.
## Installation
Run `yarn add pascal-utils -D` or `npm i pascal-utils --save-dev`.
## Usage
The documentation can be found [here](./docs/API.md).
### Compiler Detection
Run `checkCompiler().then(({ version }) => ...)` to check if the Free Pascal compiler is installed
and is in the system path.
### Compilation
Run `compile(inputFile, outputFile).then(...)` to compile a program.
## Examples
```javascript
const fs = require('fs/promises');
const pascalUtils = require('pascal-utils');
describe('Compiler detection', () => {
it('Detects compiler', () => pascalUtils.checkCompiler()
.then(() => {
expect(true).toBeTruthy();
}));
});
describe('Compilation', () => {
const exeExtension = process.platform === 'win32' ? '.exe' : '';
const sourceFile = './assets/hello.pas';
const exeName = `./hello${exeExtension}`;
it('Compiles and links', () => pascalUtils.compile(sourceFile, exeName)
.then(() => {
expect(true).toBeTruthy();
}));
afterAll(() => Promise.all([
fs.unlink('./hello.o'),
fs.unlink(exeName),
]));
});
```