pax_global_header00006660000000000000000000000064126577026130014523gustar00rootroot0000000000000052 comment=372082482ceaf2e3224bed5e80e2c869e883557e grunt-legacy-log-utils-1.0.0/000077500000000000000000000000001265770261300160375ustar00rootroot00000000000000grunt-legacy-log-utils-1.0.0/.gitignore000066400000000000000000000000151265770261300200230ustar00rootroot00000000000000node_modules grunt-legacy-log-utils-1.0.0/.jshintrc000066400000000000000000000003251265770261300176640ustar00rootroot00000000000000{ "curly": true, "eqeqeq": true, "immed": true, "latedef": "nofunc", "newcap": true, "noarg": true, "sub": true, "undef": true, "unused": true, "boss": true, "eqnull": true, "node": true } grunt-legacy-log-utils-1.0.0/.travis.yml000066400000000000000000000002611265770261300201470ustar00rootroot00000000000000sudo: false language: node_js node_js: - "0.10" - "0.12" - "4.0" - "4.1" - "4.2" - "5" - "iojs" before_install: - npm install -g npm matrix: fast_finish: true grunt-legacy-log-utils-1.0.0/Gruntfile.js000066400000000000000000000011271265770261300203350ustar00rootroot00000000000000'use strict'; module.exports = function(grunt) { grunt.initConfig({ jshint: { options: { jshintrc: '.jshintrc', }, all: ['*.js', 'test/*.js'], }, nodeunit: { util: ['test/index.js'] }, watch: { all: { files: ['<%= jshint.all %>'], tasks: ['test'], }, }, }); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-nodeunit'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('test', ['jshint', 'nodeunit']); grunt.registerTask('default', ['test', 'watch']); }; grunt-legacy-log-utils-1.0.0/LICENSE-MIT000066400000000000000000000020461265770261300174750ustar00rootroot00000000000000Copyright (c) 2016 "Cowboy" Ben Alman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. grunt-legacy-log-utils-1.0.0/README.md000066400000000000000000000007221265770261300173170ustar00rootroot00000000000000# grunt-legacy-log-utils > Static methods for the Grunt 0.4.x logger. [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-legacy-log-utils.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-legacy-log-utils) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/a6s4cy3fcbl33hnp?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-legacy-log-utils) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) grunt-legacy-log-utils-1.0.0/appveyor.yml000066400000000000000000000013411265770261300204260ustar00rootroot00000000000000# Fix line endings on Windows init: - git config --global core.autocrlf true # What combinations to test environment: matrix: - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" platform: - x86 - x64 install: - ps: Install-Product node $env:nodejs_version - npm install test_script: # Output useful info for debugging. - node --version && npm --version # We test multiple Windows shells because of prior stdout buffering issues # filed against Grunt. https://github.com/joyent/node/issues/3584 - ps: "npm test # PowerShell" # Pass comment to PS for easier debugging - cmd: npm test build: off matrix: fast_finish: true cache: - node_modules -> package.json # local npm modules grunt-legacy-log-utils-1.0.0/index.js000066400000000000000000000066021265770261300175100ustar00rootroot00000000000000/* * grunt * http://gruntjs.com/ * * Copyright (c) 2016 "Cowboy" Ben Alman * Licensed under the MIT license. * https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT */ 'use strict'; var chalk = require('chalk'); var _ = require('lodash'); // Pretty-format a word list. exports.wordlist = function(arr, options) { options = _.defaults(options || {}, { separator: ', ', color: 'cyan' }); return arr.map(function(item) { return options.color ? chalk[options.color](item) : item; }).join(options.separator); }; // Return a string, uncolored (suitable for testing .length, etc). exports.uncolor = function(str) { return str.replace(/\x1B\[\d+m/g, ''); }; // Word-wrap text to a given width, permitting ANSI color codes. exports.wraptext = function(width, text) { // notes to self: // grab 1st character or ansi code from string // if ansi code, add to array and save for later, strip from front of string // if character, add to array and increment counter, strip from front of string // if width + 1 is reached and current character isn't space: // slice off everything after last space in array and prepend it to string // etc // This result array will be joined on \n. var result = []; var matches, color, tmp; var captured = []; var charlen = 0; while (matches = text.match(/(?:(\x1B\[\d+m)|\n|(.))([\s\S]*)/)) { // Updated text to be everything not matched. text = matches[3]; // Matched a color code? if (matches[1]) { // Save last captured color code for later use. color = matches[1]; // Capture color code. captured.push(matches[1]); continue; // Matched a non-newline character? } else if (matches[2]) { // If this is the first character and a previous color code was set, push // that onto the captured array first. if (charlen === 0 && color) { captured.push(color); } // Push the matched character. captured.push(matches[2]); // Increment the current charlen. charlen++; // If not yet at the width limit or a space was matched, continue. if (charlen <= width || matches[2] === ' ') { continue; } // The current charlen exceeds the width and a space wasn't matched. // "Roll everything back" until the last space character. tmp = captured.lastIndexOf(' '); text = captured.slice(tmp === -1 ? tmp : tmp + 1).join('') + text; captured = captured.slice(0, tmp); } // The limit has been reached. Push captured string onto result array. result.push(captured.join('')); // Reset captured array and charlen. captured = []; charlen = 0; } result.push(captured.join('')); return result.join('\n'); }; // Format output into columns, wrapping words as-necessary. exports.table = function(widths, texts) { var rows = []; widths.forEach(function(width, i) { var lines = this.wraptext(width, texts[i]).split('\n'); lines.forEach(function(line, j) { var row = rows[j]; if (!row) { row = rows[j] = []; } row[i] = line; }); }, this); var lines = []; rows.forEach(function(row) { var txt = ''; var column; for (var i = 0; i < row.length; i++) { column = row[i] || ''; txt += column; var diff = widths[i] - this.uncolor(column).length; if (diff > 0) { txt += _.repeat(' ', diff); } } lines.push(txt); }, this); return lines.join('\n'); }; grunt-legacy-log-utils-1.0.0/package.json000066400000000000000000000015711265770261300203310ustar00rootroot00000000000000{ "name": "grunt-legacy-log-utils", "description": "Static methods for the Grunt 0.4.x logger.", "version": "1.0.0", "author": "\"Cowboy\" Ben Alman (http://benalman.com/)", "homepage": "http://gruntjs.com/", "repository": { "type": "git", "url": "git://github.com/gruntjs/grunt-legacy-log-utils.git" }, "bugs": { "url": "http://github.com/gruntjs/grunt-legacy-log-utils/issues" }, "license": "MIT", "main": "index.js", "files": [ "index.js" ], "scripts": { "test": "grunt test" }, "engines": { "node": ">= 0.10.0" }, "keywords": [ "grunt", "legacy" ], "dependencies": { "chalk": "~1.1.1", "lodash": "~4.3.0" }, "devDependencies": { "grunt": "~0.4.4", "grunt-cli": "~0.1.13", "grunt-contrib-jshint": "~0.10.0", "grunt-contrib-nodeunit": "~0.3.3", "grunt-contrib-watch": "~0.6.1" } } grunt-legacy-log-utils-1.0.0/test/000077500000000000000000000000001265770261300170165ustar00rootroot00000000000000grunt-legacy-log-utils-1.0.0/test/index.js000066400000000000000000000054441265770261300204720ustar00rootroot00000000000000'use strict'; var logUtils = require('../'); exports['Helpers'] = { setUp: function(done) { done(); }, 'uncolor': function(test) { test.expect(1); test.equal(logUtils.uncolor('a'.red + 'b'.bold.green + 'c'.blue.underline), 'abc'); test.done(); }, 'wordlist': function(test) { test.expect(2); test.equal(logUtils.uncolor(logUtils.wordlist(['a', 'b'])), 'a, b'); test.equal(logUtils.uncolor(logUtils.wordlist(['a', 'b'], {separator: '-'})), 'a-b'); test.done(); }, 'wraptext': function(test) { test.expect(8); // // I'm not writing out comprehensive unit tests for this right now. // function doAll(text) { // console.log('=========='); // console.log('=========='); // [4, 6, 10, 15, 20, 25, 30, 40, 60].forEach(function(n) { // doOne(n, text); // }); // } // function doOne(n, text) { // console.log(new Array(n + 1).join('-')); // console.log(logUtils.wraptext(n, text)); // } // var text = 'this is '.red + 'a simple'.yellow.inverse + ' test of'.green + ' ' + 'some wrapped'.blue + ' text over '.inverse.magenta + 'many lines'.red; // doAll(text); // text = 'foolish '.red.inverse + 'monkeys'.yellow + ' eating'.green + ' ' + 'delicious'.inverse.blue + ' bananas '.magenta + 'forever'.red; // doAll(text); // text = 'foolish monkeys eating delicious bananas forever'.rainbow; // doAll(text); test.equal(logUtils.wraptext(2, 'aabbc'), 'aa\nbb\nc'); test.equal(logUtils.wraptext(2, 'aabbcc'), 'aa\nbb\ncc'); test.equal(logUtils.wraptext(3, 'aaabbbc'), 'aaa\nbbb\nc'); test.equal(logUtils.wraptext(3, 'aaabbbcc'), 'aaa\nbbb\ncc'); test.equal(logUtils.wraptext(3, 'aaabbbccc'), 'aaa\nbbb\nccc'); test.equal(logUtils.uncolor(logUtils.wraptext(3, 'aaa'.blue + 'bbb'.green + 'c'.underline)), 'aaa\nbbb\nc'); test.equal(logUtils.uncolor(logUtils.wraptext(3, 'aaa'.blue + 'bbb'.green + 'cc'.underline)), 'aaa\nbbb\ncc'); test.equal(logUtils.uncolor(logUtils.wraptext(3, 'aaa'.blue + 'bbb'.green + 'ccc'.underline)), 'aaa\nbbb\nccc'); test.done(); }, 'table': function(test) { test.expect(1); test.equal(logUtils.table([3, 1, 5, 1, 8, 1, 12, 1, 20], [ 'a aa aaa aaaa aaaaa', '|||||||', 'b bb bbb bbbb bbbbb', '|||||||', 'c cc ccc cccc ccccc', '|||||||', 'd dd ddd dddd ddddd', '|||||||', 'e ee eee eeee eeeee eeeeee', ]), 'a |b bb |c cc ccc|d dd ddd |e ee eee eeee eeeee \n' + 'aa |bbb |cccc |dddd ddddd |eeeeee \n' + 'aaa|bbbb |ccccc | |\n' + 'aaa|bbbbb| | |\n' + 'a | | | |\n' + 'aaa| | | |\n' + 'aa | | | |'); test.done(); }, };