jscad-includify
v1.1.0
Published
Build the includes for your JSCAD project down into one file
Downloads
2
Readme
jscad-includify
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])
code
string: String of code you wish to includifybasePath
string: Path to use as the base for the includes. Defaults to an empty stringcallback
function: Function to be excuted when either an error is encountered or execution has completed. The callback is called with these parameters:error
error: If there was an error this will be the error objectincludes
array: Array of file paths that were includedcode
string: String of includified code
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:
includes
array: Array of file paths that were includedcode
string: String of includified code
Examples
// Callback example
includify.run(jscadString, (error, includes, code) => {
...
});
// Promise example
includify.run(jscadString).then((includes, code) => {
...
}).catch((error) => {
...
});
includify.runFile(inputPath[, outputPath][, callback])
inputPath
string: Path to the file you wish to includifyoutputPath
string: Path where the output is to be savedcallback
function: Function to be excuted when either an error is encountered or execution has completed. The callback is called with these parameters:error
error: If there was an error this will be the error objectincludes
array: Array of file paths that were includedcode
string: String of includified code
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:
includes
array: Array of file paths that were includedcode
string: String of includified code
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