jscad-includify
v1.1.0
Published
Build the includes for your JSCAD project down into one file
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-includifyUsage
$ jscad-includify <input file> [output file]Examples
To build the includes for logo.jscad and then output the result to stdout:
$ jscad-includify logo.jscadOr to build the includes for logo.jscad and then save the result in logo.built.jscad:
$ jscad-includify logo.jscad logo.built.jscadNode Module
Install
$ npm install --save jscad-includifyAPI
includify.run(code[, basePath][, callback])
codestring: String of code you wish to includifybasePathstring: Path to use as the base for the includes. Defaults to an empty stringcallbackfunction: Function to be excuted when either an error is encountered or execution has completed. The callback is called with these parameters:errorerror: If there was an error this will be the error objectincludesarray: Array of file paths that were includedcodestring: 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:
includesarray: Array of file paths that were includedcodestring: 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])
inputPathstring: Path to the file you wish to includifyoutputPathstring: Path where the output is to be savedcallbackfunction: Function to be excuted when either an error is encountered or execution has completed. The callback is called with these parameters:errorerror: If there was an error this will be the error objectincludesarray: Array of file paths that were includedcodestring: 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:
includesarray: Array of file paths that were includedcodestring: 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
