@folkehelseinstituttet/style
Advanced tools
Comparing version 5.9.0 to 6.0.0
{ | ||
"name": "@folkehelseinstituttet/style", | ||
"version": "5.9.0", | ||
"version": "6.0.0", | ||
"description": "CSS styling used by Folkehelseinstituttet", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,6 +11,5 @@ const fs = require('fs'); | ||
const generateIconsSASS = function() { | ||
const generateIconsSASS = function () { | ||
// start writing icons map | ||
fs.writeFile(iconsMapOutput, '$icons: (\n', error => { | ||
fs.writeFile(iconsMapOutput, '$icons: (\n', (error) => { | ||
checkForErrors(error); | ||
@@ -20,3 +19,3 @@ }); | ||
// start wrinting list of file names | ||
fs.writeFile(iconsNameList, '```scss\n$included-icons: (\n', error => { | ||
fs.writeFile(iconsNameList, '```scss\n$included-icons: (\n', (error) => { | ||
checkForErrors(error); | ||
@@ -28,4 +27,3 @@ }); | ||
const getTheFiles = function(iconsPath, arrayOfFiles) { | ||
const getTheFiles = function (iconsPath, arrayOfFiles) { | ||
const files = fs.readdirSync(iconsPath); | ||
@@ -36,3 +34,3 @@ | ||
files.forEach(function(file) { | ||
files.forEach(function (file) { | ||
let currentFile = path.join(iconsPath, '/', file); | ||
@@ -42,3 +40,3 @@ if (fs.statSync(iconsPath + '/' + file).isDirectory()) { | ||
} else if (path.parse(currentFile).ext === '.svg') { | ||
fileCounter ++; | ||
fileCounter++; | ||
@@ -51,3 +49,9 @@ fs.readFile(currentFile, { encoding: 'utf-8' }, (error, data) => { | ||
// removing all kinds of newlines, comments, xml definition and description | ||
data = data.replace(/(\r\n|\n|\r|<!--(.*?)-->|<\?xml.*?\?>|<desc>(.*?)<\/desc>)/gm, ''); | ||
data = data.replace( | ||
/(\r\n|\n|\r|<!--(.*?)-->|<\?xml.*?\?>|<desc>(.*?)<\/desc>)/gm, | ||
'', | ||
); | ||
// removing multiple spaces | ||
data = data.replace(/ +/g, ' '); | ||
data = data.replace(/>\s+</gim, '><'); | ||
@@ -59,3 +63,3 @@ currentSVG.push(`${path.parse(currentFile).name}`); | ||
iconsCounter ++; | ||
iconsCounter++; | ||
@@ -66,13 +70,18 @@ if (iconsCounter === totalNumberOfIcons) { | ||
function printList(i) { | ||
setTimeout(function() { | ||
setTimeout(function () { | ||
if (i < svgNameAndContent.length) { | ||
const content = `'${svgNameAndContent[i][0]}':'${svgNameAndContent[i][1]}',\n`; | ||
fs.appendFile(iconsMapOutput, content, 'utf-8', error => { | ||
fs.appendFile(iconsMapOutput, content, 'utf-8', (error) => { | ||
checkForErrors(error); | ||
}); | ||
fs.appendFile(iconsNameList, ` '${svgNameAndContent[i][0]}',\n`, 'utf-8', error => { | ||
checkForErrors(error); | ||
}); | ||
i ++; | ||
fs.appendFile( | ||
iconsNameList, | ||
` '${svgNameAndContent[i][0]}',\n`, | ||
'utf-8', | ||
(error) => { | ||
checkForErrors(error); | ||
}, | ||
); | ||
i++; | ||
printList(i); | ||
@@ -82,3 +91,3 @@ } else { | ||
} | ||
}, 25);// a small timeout makes sure all icons gets generated correctly | ||
}, 25); // a small timeout makes sure all icons gets generated correctly | ||
} | ||
@@ -88,10 +97,9 @@ printList(0); | ||
}); | ||
}; | ||
} | ||
}); | ||
}; | ||
const closeTheMap = function() { | ||
const closeTheMap = function () { | ||
// close up the icons map | ||
fs.appendFile(iconsMapOutput, ');\n', 'utf-8', error => { | ||
fs.appendFile(iconsMapOutput, ');\n', 'utf-8', (error) => { | ||
checkForErrors(error); | ||
@@ -101,3 +109,3 @@ }); | ||
// close up the file names list (for reference) | ||
fs.appendFile(iconsNameList, ')\n```\n', 'utf-8', error => { | ||
fs.appendFile(iconsNameList, ')\n```\n', 'utf-8', (error) => { | ||
checkForErrors(error); | ||
@@ -107,6 +115,5 @@ }); | ||
console.info(' * * * [' + iconsMapOutput + '] is generated * * *\n'); | ||
} | ||
}; | ||
const getNumberOfSVGs = function(iconsPath, svgCount) { | ||
const getNumberOfSVGs = function (iconsPath, svgCount) { | ||
files = fs.readdirSync(iconsPath); | ||
@@ -116,26 +123,26 @@ | ||
files.forEach(function(file) { | ||
files.forEach(function (file) { | ||
if (fs.statSync(iconsPath + '/' + file).isDirectory()) { | ||
svgCount = getNumberOfSVGs(iconsPath + '/' + file, svgCount); | ||
} else if (path.parse(file).ext === '.svg') { | ||
svgCount ++; | ||
svgCount++; | ||
} | ||
}) | ||
}); | ||
return svgCount; | ||
} | ||
}; | ||
const totalNumberOfIcons = getNumberOfSVGs(iconsPath); | ||
console.info('\n * * * ' + totalNumberOfIcons + ' SVG icons are found in ' + iconsPath); | ||
console.info( | ||
'\n * * * ' + totalNumberOfIcons + ' SVG icons are found in ' + iconsPath, | ||
); | ||
const sortSVGName = function(a, b) { | ||
const sortSVGName = function (a, b) { | ||
if (a[0] === b[0]) { | ||
return 0; | ||
} else { | ||
return (a[0] < b[0]) ? -1 : 1; | ||
return a[0] < b[0] ? -1 : 1; | ||
} | ||
} | ||
}; | ||
const checkForErrors = function(error) { | ||
const checkForErrors = function (error) { | ||
if (error) { | ||
@@ -145,5 +152,4 @@ console.error(error); | ||
} | ||
} | ||
}; | ||
generateIconsSASS(); |
@@ -112,2 +112,3 @@ ```scss | ||
'social', | ||
'star', | ||
'stomach', | ||
@@ -114,0 +115,0 @@ 'table', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances 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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 31 instances in 1 package
18287
3
2910596
208