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.
$ npm install -g jscad-includify
$ jscad-includify <input file> [output file]
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
$ npm install --save jscad-includify
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// Callback example
includify.run(jscadString, (error, includes, code) => {
...
});
// Promise example
includify.run(jscadString).then((includes, code) => {
...
}).catch((error) => {
...
});
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 codeIf 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// 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) => {
...
});
MIT © Luke Bonaccorsi