@knot/compiler
v1.10.0
Published
[](http://npm.im/@knot/compiler) [](https://github.com/prettier/prettier) [ to generate a new project with the minimum required boilerplate.
The source code for the compiler that is wrapped by this package can be found here;
Table of Contents
Install
npm install @knot/compiler
# or
yarn add @knot/compilerUsage
Node.js Usage
path: string
The path to the installed binary.
import { path } from '@knot/compiler';
path; // path to the knotc binaryisKnot: (fileName: string) => boolean
Test whether a file has the file extension .kn or .knot.
import { isKnot } from '@knot/compiler';
isKnot('someFile.js'); // false
isKnot('knotFile.kn'); // true
isKnot('otherFile.knot'); // trueCompiler: class KnotCompiler
A client for connecting to and managing an instance of the knot compiler.
import Compiler from '@knot/compiler';
const compiler = new Compiler({});
// add a file to the compiler
await compiler.add('./someFile.kn');
// wait for the file to be compiled
await compiler.awaitModule('./someFile.kn');
// receive the comiled file contents
const compiled = await compiler.generate('./someFile.kn');
// kill the compiler server and end the connection
await compiler.close();CLI Usage
If you install the package globally, you should be able to invoke the knotc binary installed by this package.
If you install it locally, you can invoke it from a script in your package.json file, by running yarn exec <cmd>
or in a variety of other ways.
knotc -help
# or
yarn exec knotc -- -helpCLI Arguments
-server: run the compiler in server mode-config: specify a path to the directory containing the.knot.ymlfile to load-port: specify a port for the compiler to run on, by default it runs on:1338-debug: print verbose logs-help: print usage information
Maintainers
Contributing
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
License
MIT © 2019 Ben Teichman
