{"id":20863327,"url":"https://github.com/howardabrams/jake-utils","last_synced_at":"2025-05-12T09:31:51.571Z","repository":{"id":2722036,"uuid":"3716711","full_name":"howardabrams/jake-utils","owner":"howardabrams","description":"Functions for making jake a little nicer","archived":false,"fork":false,"pushed_at":"2013-04-12T03:44:49.000Z","size":162,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T22:38:47.269Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/howardabrams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-14T10:45:44.000Z","updated_at":"2020-06-20T09:36:49.000Z","dependencies_parsed_at":"2022-09-03T12:01:35.231Z","dependency_job_id":null,"html_url":"https://github.com/howardabrams/jake-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fjake-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fjake-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fjake-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fjake-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/howardabrams","download_url":"https://codeload.github.com/howardabrams/jake-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253709162,"owners_count":21951111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T05:28:34.071Z","updated_at":"2025-05-12T09:31:51.249Z","avatar_url":"https://github.com/howardabrams.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"The `jake-utils` is a collection of useful functions for using [Jake][3].\n\n**Note:** As a package, it does un-orthodox things like creating\nglobal functions and attempting to make everything run synchronously.\nThis design decision was made in order to be consistent with Jake, and\nbehave similarly to a \"build system\".\n\n  [3]: https://github.com/isaacs/node-jake\n  \nUsage\n-----\n\nIn your `Jakefile`, simply add the following code near the top:\n\n    require('jake-utils');\n\nYou will then have a number of functions you an use.\n\n\nMocha Tests\n-----------\n\nMy favorite test harness is [Mocha][1]. \n\nYou can now do something like:\n\n    mochaTests({\n        directory: \"test\",\n        files    : /test\\-.*\\.js/,\n        coverage : true,\n        reporter : 'tap',\n        output   : 'test/results.tap'\n    });\n\nThis restores the `console.log()` before running any of the tests.\n\n**Note:** Using Mocha with [log4js][2] means that your TAP results get wonky\nwhen all `console.log()` calls get interspersed with the TAP code.\n\n [1]: https://github.com/visionmedia/mocha\n [2]: http://log4js.berlios.de/\n \n \nDisplay Messages\n----------------\n\nYou can have obnoxious headers around your tasks, to make it stand out\nmore when you are looking at builds on Jenkins.\n\n    task('api', function() {\n        start(\"Generating the Internal Documentation\");\n    \n        // ...\n        \n        end(\"View documents in '%s'\", apidest);\n    });\n\n\nLint Analysis using JSHint\n--------------------------\n\nWe have a nice wrapper around the [JSHint][4] utility for analyzing all\nthe files found in the directories specified. For example:\n\n    desc(\"Lints all of the script files in the source directories\");\n    task('lint', function(){\n        start(\"Analyzing the Script Files\");\n    \n        var codelib    = [ 'services' , 'routes', 'resources' ];\n        lint( codelib );\n    \n        end();\n    });\n    \n  [4]: https://github.com/jshint/node-jshint/\n\n\nConcatenate files\n--------------------------\n\nThe method `concat` is available to concatenate multiple files into one.\nThe method resolves patterns in filenames, and has options to add a header,\nseparators, and a footer to the concatenated file. Example:\n\n    desc(\"Concatenates all source files into library\");\n    task('concat', function(){\n        start(\"Concatenating the source files\");\n\n        var result = concat({\n            src: [\n                './src/main.js',\n                './src/extra.js',\n                './src/functions/**',\n            ],\n            dest: './lib/mylibrary.js',           // optional\n            header: '// license information...',  // optional\n            separator: '\\n',                      // optional\n            footer: '// the end...'               // optional\n        });\n\n        // returned result is an object containing:\n        //     {String} code   The concatenated data\n        //     {String} src    The list with resolved filenames\n\n        end();\n    });\n\nMarkdown File Conversion\n------------------------\n\nThe `markdown` function converts a markdown-formatted file into an HTML file using the\n[marked parser](https://github.com/chjj/marked).\n\n    desc(\"Converts README into HTML File);\n    task('readme', function(){\n        start(\"Converting the README into a web page\");\n        markdown( \"README.md\", \"pub/README.html\");\n        end();\n    });\n\nThe function takes an optional third parameter for `marked`-specific options.\n\n\nMinify using uglify-js\n--------------------------\n\nThe method `minify` is available to minify a source file using [uglify-js][5].\nThe method accepts one source file, or an array with multiple source files, and\nresolves patterns in the filenames. Example:\n\n    desc(\"Minify the library\");\n    task('minify', function(){\n        start(\"Minifying library\");\n\n        var result = minify({\n            src:  './lib/mylibrary.js',\n            dest: './lib/mylibrary.min.js',       // optional\n            options: {},                          // uglify-js options. optional\n            header: '// license information...',  // optional\n            separator: '\\n',                      // optional\n            footer: '// the end...'               // optional\n        });\n\n        // returned result is an object containing:\n        //     {String} code   The concatenated data\n        //     {String} src    The list with resolved filenames\n\n        end();\n    });\n\n  [5]: https://github.com/mishoo/UglifyJS2\n\n\nReplace patterns in files\n--------------------------\n\nThe method `replace` can be used to replace patterns in files, for example to\nfill in today's date or the version number of the package. The patterns can\nbe a string or a regular expression. The list with source files can contain\npatterns. Example:\n\n    desc(\"Replace version and date in source files\");\n    task('replace', function(){\n        start(\"Replace version and date in source files\");\n\n        var result = replace({\n            replacements: [\n                {pattern: '@@date',    replacement: today()},\n                {pattern: '@@version', replacement: version()}\n            },\n            src: [\n             'main.js',\n             'other/*.js'\n            ]\n        });\n\n        // returned result is an object containing:\n        //     {String} src    The list with resolved filenames\n\n        end();\n    });\n\n  [5]: https://github.com/mishoo/UglifyJS2\n\n\nUtility functions\n--------------------------\n\nOther utility methods are:\n\n    var p = pkg();              // package.json contents\n    var v = version();          // version number from package.json\n    var d = today();            // formatted date of today\n    var data = read(filename);  // read data (fs.readFileSync)\n    write(filename, data);      // write data (fs.writeFileSync)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Fjake-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhowardabrams%2Fjake-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Fjake-utils/lists"}