Comparing version 3.2.0 to 3.3.0
@@ -41,3 +41,2 @@ /*************************************************************************************************************************************************************** | ||
} | ||
if (charWidth === 0 && letterSpacing > 0) { | ||
@@ -44,0 +43,0 @@ Debugging.report(`CharLength: Adding space to letter spacing`, 1); |
@@ -211,2 +211,9 @@ export const CHARS: string[]; | ||
}; | ||
'--raw-mode': { | ||
description: string; | ||
example: string; | ||
short: string; | ||
fallback_shortcut: boolean; | ||
default: boolean; | ||
}; | ||
'--env': { | ||
@@ -213,0 +220,0 @@ description: string; |
@@ -211,2 +211,9 @@ /*************************************************************************************************************************************************************** | ||
}, | ||
'--raw-mode': { | ||
description: 'Use to enable proper newline rendering in raw mode in the terminal by adding \\r to line breaks', | ||
example: '--raw-mode', | ||
short: '-r', | ||
fallback_shortcut: false, | ||
default: false | ||
}, | ||
'--env': { | ||
@@ -213,0 +220,0 @@ description: 'Use to define what environment you run CFonts in.', |
@@ -54,3 +54,3 @@ /*************************************************************************************************************************************************************** | ||
const args = ParseArgs(inputOptions, inputArgs); | ||
Debugging.report(`OPTIONS:\n` + ` CFonts.say("${args.text}", {\n` + ` font: "${args.font}",\n` + ` align: "${args.align}",\n` + ` colors: ${args.colors ? JSON.stringify(args.colors.split(',')) : []},\n` + ` background: "${args.background}",\n` + ` letterSpacing: ${args['letter-spacing']},\n` + ` lineHeight: ${args['line-height']},\n` + ` space: ${!args.spaceless},\n` + ` maxLength: ${args['max-length']},\n` + ` gradient: ${args.gradient},\n` + ` independentGradient: ${args['independent-gradient']},\n` + ` transitionGradient: ${args['transition-gradient']},\n` + ` env: ${args.env},\n` + ` }, ${args.debug}, ${args.debugLevel} );`, 3, args.debug, args.debugLevel); | ||
Debugging.report(`OPTIONS:\n` + ` CFonts.say("${args.text}", {\n` + ` font: "${args.font}",\n` + ` align: "${args.align}",\n` + ` colors: ${args.colors ? JSON.stringify(args.colors.split(',')) : []},\n` + ` background: "${args.background}",\n` + ` letterSpacing: ${args['letter-spacing']},\n` + ` lineHeight: ${args['line-height']},\n` + ` spaceless: ${args.spaceless},\n` + ` maxLength: ${args['max-length']},\n` + ` gradient: ${args.gradient},\n` + ` independentGradient: ${args['independent-gradient']},\n` + ` transitionGradient: ${args['transition-gradient']},\n` + ` rawMode: ${args['raw-mode']},\n` + ` env: ${args.env},\n` + ` }, ${args.debug}, ${args['debug-level']} );`, 3, args.debug, args['debug-level']); | ||
if (args.help) { | ||
@@ -79,3 +79,3 @@ DisplayHelp(); | ||
lineHeight: args['line-height'], | ||
space: !args.spaceless, | ||
spaceless: args.spaceless, | ||
maxLength: args['max-length'], | ||
@@ -85,4 +85,5 @@ gradient: args.gradient, | ||
transitionGradient: args['transition-gradient'], | ||
rawMode: args['raw-mode'], | ||
env: args.env | ||
}, args.debug, args.debugLevel); | ||
}, args.debug, args['debug-level']); | ||
}; | ||
@@ -89,0 +90,0 @@ module.exports = exports = { |
@@ -39,3 +39,3 @@ /*************************************************************************************************************************************************************** | ||
lineHeight: 1, | ||
space: true, | ||
spaceless: false, | ||
maxLength: 0, | ||
@@ -45,2 +45,3 @@ gradient: false, | ||
transitionGradient: false, | ||
rawMode: false, | ||
env: 'node' | ||
@@ -52,3 +53,2 @@ }; | ||
}, | ||
/** | ||
@@ -73,3 +73,3 @@ * Get the current options | ||
* @param {number} options.lineHeight - Space between lines, Default: 1 | ||
* @param {boolean} options.space - Output space before and after output, Default: true | ||
* @param {boolean} options.spaceless - Don't output space before and after output, Default: false | ||
* @param {number} options.maxLength - Maximum amount of characters per line, Default width of console window | ||
@@ -83,2 +83,3 @@ * @param {(string|array|boolean)} options.gradient - Gradient color pair, Default: false | ||
* @param {object} options.allowedFont - All allowed fontfaces | ||
* @param {boolean} options.rawMode - A switch for raw mode in terminals | ||
*/ | ||
@@ -93,3 +94,3 @@ set set({ | ||
lineHeight, | ||
space, | ||
spaceless, | ||
maxLength, | ||
@@ -102,3 +103,4 @@ gradient, | ||
allowedBG = BGCOLORS, | ||
allowedFont = FONTFACES | ||
allowedFont = FONTFACES, | ||
rawMode | ||
}) { | ||
@@ -112,3 +114,3 @@ this.store.font = font !== '' ? allowedFont[font.toLowerCase()] || font : this.store.font; | ||
this.store.lineHeight = lineHeight !== undefined ? parseInt(lineHeight.toString()) : font.toLowerCase() === 'console' ? 0 : this.store.lineHeight; | ||
this.store.space = typeof space === 'boolean' ? space : this.store.space; | ||
this.store.spaceless = typeof spaceless === 'boolean' ? spaceless : this.store.spaceless; | ||
this.store.maxLength = maxLength !== undefined ? maxLength : this.store.maxLength; | ||
@@ -119,2 +121,3 @@ this.store.gradient = gradient !== undefined && typeof gradient !== 'boolean' ? Array.isArray(gradient) ? gradient : gradient.split(',') : gradient === false ? false : this.store.gradient; | ||
this.store.env = env !== undefined ? env : this.store.env; | ||
this.store.rawMode = rawMode !== undefined ? rawMode : this.store.rawMode; | ||
} | ||
@@ -121,0 +124,0 @@ }; |
@@ -144,2 +144,7 @@ /*************************************************************************************************************************************************************** | ||
// handle raw mode | ||
let line_break = '\n'; | ||
if (OPTIONS.env === 'node' && OPTIONS.rawMode === true) { | ||
line_break = '\r\n'; | ||
} | ||
output = AddLine([], FONTFACE.lines, FONTFACE.buffer, OPTIONS.lineHeight); // create first lines with buffer | ||
@@ -166,3 +171,2 @@ lines++; | ||
} | ||
lineLength += CharLength(FONTFACE.letterspace, FONTFACE.lines, OPTIONS) * OPTIONS.letterSpacing; // each new line starts with letter spacing | ||
@@ -176,3 +180,2 @@ lineLength = CharLength(FONTFACE.buffer, FONTFACE.lines, OPTIONS); // new line: new line length | ||
} | ||
maxChars = 0; // new line, new maxLength goal | ||
@@ -183,3 +186,2 @@ | ||
} | ||
Debugging.report(`lineLength at: "${lineLength}"`, 2); | ||
@@ -192,7 +194,5 @@ if (CHAR !== `|`) { | ||
} | ||
if (OPTIONS.env === 'node') { | ||
output = AlignText(output, lineLength, FONTFACE.lines, OPTIONS.align, size); // alignment last line | ||
} | ||
if (OPTIONS.gradient) { | ||
@@ -209,11 +209,11 @@ output = PaintGradient({ | ||
} | ||
if (OPTIONS.space) { | ||
if (!OPTIONS.spaceless) { | ||
// add space | ||
if (OPTIONS.align === 'top') { | ||
output[output.length - 1] = `${output[output.length - 1]}\n\n\n\n`; | ||
output[output.length - 1] = `${output[output.length - 1]}${line_break}${line_break}${line_break}${line_break}`; | ||
} else if (OPTIONS.align === 'bottom') { | ||
output[0] = `\n\n\n\n${output[0]}`; | ||
output[0] = `${line_break}${line_break}${line_break}${line_break}${output[0]}`; | ||
} else { | ||
output[0] = `\n\n${output[0]}`; | ||
output[output.length - 1] = `${output[output.length - 1]}\n\n`; | ||
output[0] = `${line_break}${line_break}${output[0]}`; | ||
output[output.length - 1] = `${output[output.length - 1]}${line_break}${line_break}`; | ||
} | ||
@@ -226,6 +226,6 @@ } | ||
} = Color(OPTIONS.background, true); | ||
output[0] = `${openNew}\n${output[0]}`; | ||
output[0] = `${openNew}${line_break}${output[0]}`; | ||
output[output.length - 1] = `${output[output.length - 1]}${closeNew}`; | ||
} | ||
let write = output.join(OPTIONS.env === 'node' ? `\n` : '<br>\n'); | ||
let write = output.join(OPTIONS.env === 'node' ? `${line_break}` : `<br>${line_break}`); | ||
if (OPTIONS.env === 'browser') { | ||
@@ -232,0 +232,0 @@ const { |
@@ -49,5 +49,4 @@ /*************************************************************************************************************************************************************** | ||
}; | ||
module.exports = exports = { | ||
Say | ||
}; |
{ | ||
"name": "cfonts", | ||
"description": "Sexy ANSI fonts for the console", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"homepage": "https://github.com/dominikwilkowski/cfonts", | ||
@@ -27,3 +27,3 @@ "author": { | ||
"scripts": { | ||
"test": "yarn format && yarn build && yarn test:unit && yarn test:lint && yarn test:types && yarn test:fonts", | ||
"test": "yarn test:format && yarn build && yarn test:unit && yarn test:lint && yarn test:types && yarn test:fonts", | ||
"test:fonts": "node ./test/fonttest.js", | ||
@@ -34,3 +34,3 @@ "test:watch": "jest --watchAll --coverage", | ||
"test:lint": "eslint src/", | ||
"test:format": "prettier --list-different \"**/*.{js,json}\"", | ||
"test:format": "prettier --version && prettier --list-different \"**/*.{js,json}\"", | ||
"format": "prettier --write \"**/*.{js,json}\"", | ||
@@ -40,3 +40,3 @@ "build": "yarn build:lib && yarn build:bin && yarn build:fonts", | ||
"build:lib": "npx mkdirp lib && babel src --out-dir lib", | ||
"build:fonts": "npx mkdirp fonts && npx cpy-cli \"../fonts/*\" \"./fonts/\"", | ||
"build:fonts": "make", | ||
"types:clean": "npx trash-cli \"lib/*.d.ts\"", | ||
@@ -48,12 +48,12 @@ "watch": "yarn build:lib && onchange 'src/**/*' -- yarn build:lib", | ||
"devDependencies": { | ||
"@babel/cli": "^7.21.0", | ||
"@babel/core": "^7.21.3", | ||
"@babel/preset-env": "^7.20.2", | ||
"@types/node": "latest", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^8.36.0", | ||
"@babel/cli": "^7", | ||
"@babel/core": "^7", | ||
"@babel/preset-env": "^7", | ||
"@types/node": "^20", | ||
"coveralls": "^3", | ||
"eslint": "^8", | ||
"jest-cli": "^27", | ||
"onchange": "^7.1.0", | ||
"prettier": "^2.8.7", | ||
"typescript": "^5.0.2" | ||
"onchange": "^7", | ||
"prettier": "^2", | ||
"typescript": "5.0" | ||
}, | ||
@@ -63,3 +63,3 @@ "peerDependencies": {}, | ||
"supports-color": "^8", | ||
"window-size": "^1.1.1" | ||
"window-size": "^1" | ||
}, | ||
@@ -66,0 +66,0 @@ "jest": { |
@@ -60,2 +60,3 @@ ```sh | ||
transitionGradient: false, // define if this is a transition between colors directly | ||
rawMode: false, // define if the line breaks should be CRLF (`\r\n`) over the default LF (`\n`) | ||
env: 'node' // define the environment cfonts is being executed in | ||
@@ -95,8 +96,15 @@ }); | ||
| Linux | v16 | | ||
| MacOS | v12 | | ||
| MacOS | v14 | | ||
| Linux | v18 | | ||
| Linux | v20 | | ||
| Linux | v22 | | ||
| MacOS | v16 | | ||
| MacOS | v18 | | ||
| MacOS | v20 | | ||
| MacOS | v22 | | ||
| Windows | v12 | | ||
| Windows | v14 | | ||
| Windows | v16 | | ||
| Windows | v18 | | ||
| Windows | v20 | | ||
| Windows | v22 | | ||
@@ -166,2 +174,3 @@ ### Unit tests | ||
* 3.3.0 - Added raw-mode flag, bumped dependencies | ||
* 3.2.0 - Added TS type to the published npm package | ||
@@ -168,0 +177,0 @@ * 3.1.1 - Fixed #58 gradient color bug, added `gray` to gradient colors |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
331954
69
9493
244
3
Updatedwindow-size@^1