travis-target

0.2.0 • Public • Published

travis-target Build Status

This module is used to determine the target files or directories of a Travis CI build. It accomplishes that by examining the git history for repository being tested, and comparing the current git commit hash with the last hash on origin/master.

Getting Started

First thing's first, install the module:

npm install travis-target --save-dev
const { target } = require('travis-target');
 
let options = {};
let targets = await target(options);

Requirements

Node.js version 7 or higher is recommended. This module makes use of async / await patterns. Code using this module should be run as such:

node --harmony-async-await app

Or you can use harmonize at the start of your app entry point file:

require('harmonize')(['harmony-async-await']);

If you can't use version 7, use Babel.js to handle runtime transpilation. My pattern is to use an index.js file which sets up Babel and calls out to the app entry point:

require('babel-core/register');
require('babel-polyfill');
require('./app');

target Options

The module's target accepts an options Object, which can contain options for the webpack-dev-middleware and webpack-hot-middleware bundled with this module. The following is a property reference for the Object:

map

Type: Function
optional

Note: Results are filtered using pattern prior to any mapping.

Should you have the need to perform advanced mapping of the results, specify a function for the map property which accepts a lone target parameter.

Example:

const { target } = require('travis-target');
 
let options = { map: (target) => { ... } };
let targets = await target(options);

pattern

Type: RegExp
optional

If you'd like the target results to be filtered by a particular pattern, assign a regular expression to this property, and the results will only contain targets which match the pattern.

To exclude results that match a pattern, use a negative look-ahead RegExp.

Example:

const { target } = require('travis-target');
 
// only return targets that begin with 'src/'
let options = { pattern: /^src\//gi };
let targets = await target(options);

Testing

npm install
npm install gulp -g
gulp

Contributing

We welcome your contributions! Please have a read of CONTRIBUTING.

Readme

Keywords

Package Sidebar

Install

npm i travis-target

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • shellscape