CodeFoodPixels / jscad-includify

Build the includes for your JSCAD project down into one file
MIT License
5 stars 1 forks source link

jscad-includify

Build Status Greenkeeper badge

Build the includes for your JSCAD project down into one file. Helpful for distributing a utility library or a project as a single file.

This module can be used both as a CLI tool and as a node module.

CLI Tool

Install

$ npm install -g jscad-includify

Usage

$ jscad-includify <input file> [output file]

Examples

To build the includes for logo.jscad and then output the result to stdout:

$ jscad-includify logo.jscad

Or to build the includes for logo.jscad and then save the result in logo.built.jscad:

$ jscad-includify logo.jscad logo.built.jscad

Node Module

Install

$ npm install --save jscad-includify

API

includify.run(code[, basePath][, callback])

If callback is ommitted then a promise is returned. If there is an error, the promise will be rejected with the error object. If the execution is successful, the promise will be fulfilled with an object containing the following:

Examples
// Callback example
includify.run(jscadString, (error, includes, code) => {
    ...
});

// Promise example
includify.run(jscadString).then((includes, code) => {
    ...
}).catch((error) => {
    ...
});

includify.runFile(inputPath[, outputPath][, callback])

If callback is ommitted then a promise is returned. If there is an error, the promise will be rejected with the error object. If the execution is successful, the promise will be fulfilled with an object containing the following:

Examples
// Callback example excluding output path
includify.runFile(`logo.jscad`, (error, includes, code) => {
    ...
});

// Callback example with output path
includify.runFile(`logo.jscad`, `logo.built.jscad`, (error, includes, code) => {
    ...
});

// Promise example with output path
includify.runFile(`logo.jscad`).then((includes, code) => {
    ...
}).catch((error) => {
    ...
});

// Promise example excluding output path
includify.runFile(`logo.jscad`, `logo.built.jscad`).then((includes, code) => {
    ...
}).catch((error) => {
    ...
});

License

MIT © Luke Bonaccorsi