pascal-utils
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

Pascal Utils

GitHub npm version Unit Tests codecov

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

Contents

  1. Requirements
  2. Installation
  3. Usage
    1. Compiler Detection
    2. Compilation
  4. 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.

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

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),
  ]));
});

Readme

Keywords

Package Sidebar

Install

npm i pascal-utils

Weekly Downloads

1

Version

2.0.2

License

MIT

Unpacked Size

22.2 kB

Total Files

30

Last publish

Collaborators

  • synthetic.borealis