From e725eb4185f86fb61a66ad5d9a68936a95dcb31a Mon Sep 17 00:00:00 2001 From: Hale Rankin Date: Mon, 14 Oct 2019 13:23:40 -0700 Subject: [PATCH] Add new option to prefix without numbers. This new option is set to true by default, so number will not appear in generated sass variables. --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 1d73ea6..be514d8 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,8 @@ module.exports = function(opt) { opt.escapeIllegalCharacters = opt.escapeIllegalCharacters === undefined ? true : opt.escapeIllegalCharacters; opt.firstCharacter = opt.firstCharacter || '_'; opt.prefixFirstNumericCharacter = opt.prefixFirstNumericCharacter === undefined ? true : opt.prefixFirstNumericCharacter; - + opt.prefixNoNumbers = opt.prefixNoNumbers === undefined ? true : opt.prefixNoNumbers; + return through(processJSON); ///////////// @@ -75,9 +76,13 @@ module.exports = function(opt) { // sass variables cannot begin with a number if (path === '' && firstCharacterIsNumber.exec(key) && opt.prefixFirstNumericCharacter) { - key = opt.firstCharacter + key; + if (opt.prefixNoNumbers) { + key = opt.firstCharacter; + } else { + key = opt.firstCharacter + key; + } } - + if (typeof val !== 'object') { cb('$' + path + key + ': ' + val + opt.eol); } else {