0.3.0 • Published 2 years ago

building v0.3.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Building Build Status

Whatever good things we build end up building us. (Jim Rohn)

Building helps you write custom tasks for your favorite build tool.

Installation

npm install building --save-dev

Usage

// require the whole module...
var building = require('building');

// or specific parts
var files = require('building').files;

return files.writeJson('/tmp/file.json', {hello:'world'});

Promise friendly

All methods tend to manipulate I/O and thus are asynchronous. They use exclusively promises.

building module

The building module exposes the following helpers:

  • files
  • shell

building.files

var files = require('building').files;

glob(pattern, options)

  • return: {Promise}

Promisification of glob method from glob module. The documentation is available on glob repository.

copyFiles(filePaths, destinationDirectory, options)

  • filePaths {Array<String>} The file paths to copy
  • destinationDirectory {String} The destination directory
  • options {Object}
  • return: {Promise}

Copy given files at the root of the destination directory.

Options

  • preservePathAfter {String} Copy files but preserve the path after the given one. Example: when copying src/assets/js/file.js into dist, you may want to preserve the path after src/assets to obtain dist/js/file.js.

globAndCopyFiles(globbing, destinationDirectory, options)

  • globbing {Object} The globbing information
  • destinationDirectory {String} The destination directory
  • options {Object}
  • return: {Promise}

Glob files then copy them like copyFiles.

Globbing

The globbing object contains:

  • pattern
  • options

They correspond to the arguments of the glob method.

Options

Same options as building.files.copyFiles.

writeContent(destination, content)

  • destination {String} The destination file, existing or not
  • content {String} The content to write
  • return: {Promise}

Write content to an existing file or create it before.

writeJson(destination, object)

  • destination {String} The destination file, existing or not
  • object {Object} The object to write as JSON
  • return: {Promise}

Write object as JSON to an existing file or create it before.

building.shell

var shell = require('building').shell;

execute(binary, args, options)

  • binary {String} The binary to execute
  • args {Array<String>} The arguments to pass
  • options {Object}
  • return: {Promise}

Execute a binary with its arguments.

Options

  • resolveLocalBin {Boolean} (default: false) Set to true to resolve binary from local node_modules binary. Example if binary is jshint and resolveLocalBin is true, the resolved binary is ./node_modules/.bin/jshint.

executeLocal(binary, args, options)

Shortcut to execute with resolveLocalBin option set to true.

createExecution(binary, args, options)

  • binary {String} The binary to execute
  • args {Array<String>} The arguments to pass
  • options {Object}
  • return: {Object} containing:
    • value {ChildProcess} The standard Node.JS child process
    • promise {Promise} The execution promise

Like building.shell.execute but returns an execution object to access the child process.

Options

Same options as building.shell.execute.

License

MIT

0.3.0

2 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.0.2

9 years ago

0.0.1

9 years ago