css-modules-flow-types-printer
Advanced tools
Comparing version
@@ -6,3 +6,4 @@ 'use strict'; | ||
}); | ||
exports.HEADER = undefined; | ||
exports.EOL = exports.HEADER = undefined; | ||
exports.getLineSeparator = getLineSeparator; | ||
exports.default = printFlowDefinition; | ||
@@ -19,6 +20,19 @@ | ||
const EOL = exports.EOL = { | ||
LF: '\n', | ||
CRLF: '\r\n' | ||
}; | ||
function getLineSeparator(content) { | ||
if (typeof content !== 'string') return _os2.default.EOL; | ||
if (content.includes(EOL.CRLF)) return EOL.CRLF; | ||
if (content.includes(EOL.LF)) return EOL.LF; | ||
return _os2.default.EOL; | ||
} | ||
function printFlowDefinition(tokensArray) { | ||
let indent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' '; | ||
let eol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _os2.default.EOL; | ||
let indent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' '; | ||
const props = tokensArray.sort().map(key => `${indent}+'${key}': string;`).join(_os2.default.EOL); | ||
const props = tokensArray.sort().map(key => `${indent}+'${key}': string;`).join(eol); | ||
@@ -25,0 +39,0 @@ return `${HEADER} |
{ | ||
"name": "css-modules-flow-types-printer", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Prints CSS Modules tokens as a flow definition", | ||
@@ -5,0 +5,0 @@ "author": "skovhus", |
2354
22.22%31
63.16%