How to use the jake.FileList function in jake

To help you get started, we’ve selected a few jake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github almende / vis / Jakefile.js View on Github external
task('test', function () {
  // TODO: use a testing suite for testing: nodeunit, mocha, tap, ...
  var filelist = new jake.FileList();
  filelist.include([
    './test/**/*.js'
  ]);

  var files = filelist.toArray();
  files.forEach(function (file) {
    require('./' + file);
  });

  console.log('Executed ' + files.length + ' test files successfully');
});
github howardabrams / jake-utils / minify.js View on Github external
if (!(params.options instanceof Object)) {
            throw new Error('Parameter "options" must be an object.');
        }
    }

    var code = '';
    var separator = params.separator ? String(params.separator) : '';
    var options = params.options || {};

    // header
    if (params.header) {
        code += String(params.header) + separator;
    }

    // src
    var filelist = new jake.FileList();
    filelist.include(params.src);
    var filenames = filelist.toArray();
    var minified = uglify.minify(filenames, options);
    code += minified.code;

    // footer
    if (params.footer) {
        code += separator + String(params.footer);
    }

    // write output
    if (params.dest) {
        write(params.dest, code);
    }

    return {
github cappuccino / cappuccino / Objective-J / CommonJS / lib / objective-j / compiler.js View on Github external
}
        finally
        {
            p.stdin.close();
            p.stdout.close();
            p.stderr.close();
        }

        return fileContents;
    }

    // Preprocess contents into fragments.
    // FIXME: should calculate relative path, etc.
    try
    {
        var sources = new JAKE.FileList("**/*.j"),
            translateFilenameToPath = {},
            otherwayTranslateFilenameToPath = {};

        // Create a filename to filename path dictionary. (For example: CPArray.j -> CPArray/CPArray.j)
        sources.forEach(function(/*String*/ aFilename)
        {
            translateFilenameToPath[FILE.basename(aFilename)] = aFilename;
            otherwayTranslateFilenameToPath[aFilename] = FILE.basename(aFilename);
        }, this);

        var translatedFilename = translateFilenameToPath[aFilePath] ? translateFilenameToPath[aFilePath] : aFilePath,
            otherwayTranslatedFilename = otherwayTranslateFilenameToPath[aFilePath] ? otherwayTranslateFilenameToPath[aFilePath] : aFilePath,
            theTranslatedFilename = otherwayTranslatedFilename ? otherwayTranslatedFilename : translatedFilename,
            absolutePath = FILE.absolute(theTranslatedFilename),
            basePath = absolutePath.substring(0, absolutePath.length - theTranslatedFilename.length);
github howardabrams / jake-utils / replace.js View on Github external
function replace (params) {
    // do some checks on the provided parameters
    if (!(params instanceof Object)) {
        throw new Error('Object with parameters expected as first argument.');
    }
    if (!params.replacements) {
        throw new Error('Parameter "replacements" missing.');
    }
    if (!(params.replacements instanceof Array)) {
        throw new Error('Parameter "replacements" must be an array.');
    }
    if (!params.src) {
        throw new Error('Parameter "src" containing an array with filenames missing.');
    }

    var filelist = new jake.FileList();
    filelist.include(params.src);
    var filenames = filelist.toArray();

    filenames.forEach(function (filename) {
        var file = String(read(filename));
        params.replacements.forEach(function (replacement, index) {
            // check the replacement parameters
            if (!(replacement instanceof Object)) {
                throw new Error('Parameter "replacement" must be an object.');
            }
            if (!replacement.pattern) {
                throw new Error('Parameter "pattern" in missing replacement object ' +
                    '(index ' + index + ')');
            }
            if (!replacement.replacement) {
                throw new Error('Parameter "replacement" missing in replacement object ' +
github josdejong / mathjs / tools / jake-utils.js View on Github external
function replace (params) {
  // do some checks on the provided parameters
  if (!(params instanceof Object)) {
    throw new Error('Object with parameters expected as first argument.');
  }
  if (!params.replacements) {
    throw new Error('Parameter "replacements" missing.');
  }
  if (!Array.isArray(params.replacements)) {
    throw new Error('Parameter "replacements" must be an array.');
  }
  if (!params.src) {
    throw new Error('Parameter "src" containing an array with filenames missing.');
  }

  var filelist = new jake.FileList();
  filelist.include(params.src);
  var filenames = filelist.toArray();

  filenames.forEach(function (filename) {
    var file = String(read(filename));
    params.replacements.forEach(function (replacement, index) {
      // check the replacement parameters
      if (!(replacement instanceof Object)) {
        throw new Error('Parameter "replacement" must be an object.');
      }
      if (!replacement.pattern) {
        throw new Error('Parameter "pattern" in missing replacement object ' +
            '(index ' + index + ')');
      }
      if (!replacement.replacement) {
        throw new Error('Parameter "replacement" missing in replacement object ' +
github eslint / eslint / Jakefile.js View on Github external
var eslint = require("./lib/eslint"),
    fs = require("fs"),
    path = require("path"),
    existsSync = fs.existsSync || path.existsSync;

//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------

var ISTANBUL_CLI    = "./node_modules/istanbul/lib/cli.js",
    VOWS_CLI        = "./node_modules/vows/bin/vows",
    JSHINT_CLI      = "node_modules/jshint/bin/jshint",
    ESLINT_CLI      = "./bin/eslint",
    ESLINT_CONFIG   = "./tests/eslint.json",
    COVERAGE_THRESHOLDS = "--statement 90 --branch 90 --function 90",
    LINTABLE_FILES  = (new jake.FileList().include("package.json").include("./conf/*.json").include("lib")).toArray().join(" ").replace(/\\/g, "/"),
    ESLINT_LINTABLE_FILES  = (new jake.FileList().include("lib")).toArray().join(" ").replace(/\\/g, "/"),
    TEST_FILES      = (new jake.FileList().include("tests/*.js").exclude("tests/fixtures/*.js").exclude("tests/performance/*.js").include("tests/*/*.js").include("tests/*/*/*.js")).toArray().join(" ").replace(/\\/g, "/");

//npm run-script lint && node $istanbul cover --print both $vows -- --spec $testfiles && node $istanbul check-coverage $thresholds

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

/**
 * Runs JSHint on the given files.
 * @param {string} files A space-separated list of filenames to lint.
 * @param {Function} callback The function to call when complete.
 * @returns {void}
 */
function jshint(files, callback) {
github jamesshore / automatopia / build / util / mocha_runner.js View on Github external
function deglob(globs) {
		return new jake.FileList(globs).toArray();
	}
github cappuccino / cappuccino / Tests / DetectMissingImports.js View on Github external
{
                            var hashKey = fileName + e.message;
                            if (!errorMessageHashSet[hashKey])
                            {
                                stream.print("\0yellow(Detected missing @import in \"" + fileName + "\": " + e.message +  " (Context: [" + className + " " + methodName + "])\0)");
                                errorMessageHashSet[hashKey] = true;
                            }
                        }
                    }
                }
            }
        }
    }
};

(new FileList("Foundation/**.j").include("AppKit/**.j")).forEach(function (aFile)
{
    checkImportsForFile(aFile);
});