Code coverage report for yeoman-generator/lib/actions/file.js

Statements: 100% (16 / 16)      Branches: 100% (4 / 4)      Functions: 100% (4 / 4)      Lines: 100% (16 / 16)      Ignored: none     

All files » yeoman-generator/lib/actions/ » file.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  1 1 1 1   1                     1 15                         1 15 15 15 1814                 1 2144 2144     1  
'use strict';
var fs = require('fs');
var path = require('path');
var glob = require('glob');
var mkdirp = require('mkdirp');
 
var file = module.exports;
 
/**
 * Performs a glob search with the provided pattern and optional Hash of
 * options. Options can be any option supported by
 * [glob](https://github.com/isaacs/node-glob#options)
 *
 * @param {String} pattern
 * @param {Object} options
 */
 
file.expand = function expand(pattern, options) {
  return glob.sync(pattern, options);
};
 
/**
 * Performs a glob search with the provided pattern and optional Hash of
 * options, filtering results to only return files (not directories). Options
 * can be any option supported by
 * [glob](https://github.com/isaacs/node-glob#options)
 *
 * @param {String} pattern
 * @param {Object} options
 */
 
file.expandFiles = function expandFiles(pattern, options) {
  options = options || {};
  var cwd = options.cwd || process.cwd();
  return this.expand(pattern, options).filter(function (filepath) {
    return fs.statSync(path.join(cwd, filepath)).isFile();
  });
};
 
/**
 * Checks a given file path being absolute or not.
 * Borrowed from grunt's file API.
 */
 
file.isPathAbsolute = function () {
  var filepath = path.join.apply(path, arguments);
  return path.resolve(filepath) === filepath;
};
 
file.mkdir = mkdirp.sync.bind(mkdirp);