Build the includes for your JSCAD project down into one file
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE
README.md
cli.js
index.js
package-lock.json
package.json

README.md

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])

  • code string: String of code you wish to includify
  • basePath string: Path to use as the base for the includes. Defaults to an empty string
  • callback 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 object
    • includes array: Array of file paths that were included
    • code 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 included
  • code 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 includify
  • outputPath string: Path where the output is to be saved
  • callback 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 object
    • includes array: Array of file paths that were included
    • code 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 included
  • code 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