Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

files-to-sass

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

files-to-sass - npm Package Compare versions

Comparing version 0.2.1 to 0.2.3

25

index.js
var fs = require('fs'),
chalk = require('chalk');
function filesAsVariables(fileName, fileContents) {
return '$' + fileName + ': \'' + fileContents + '\'\;\n';
}
function filesAsSassMap(fileName, fileContents) {
return ' ' + fileName + ': \'' + fileContents + '\'\n';
}
var fileAs = filesAsVariables;
var options = {
debug: false,
sassMap: false,
sassMapName: 'fileMap'
};
module.exports = function (options) {

@@ -17,2 +33,6 @@ if (!options) {

if (options.sassMap && options.sassMap === true) {
fileAs = filesAsSassMap;
}
options.files = fs.readdirSync(options.src);

@@ -27,9 +47,10 @@ options.fileList = {};

options.fileList[fileName] = fileContents.replace(/\n|\r/gi, '');
options.content += '$' + fileName + ': \'' + options.fileList[fileName] + '\'\;\n';
options.content += fileAs(fileName, options.fileList[fileName]);
if(options.debug) {
console.log('Processing file ' + chalk.cyan(file));
console.log('Processed file ' + chalk.cyan(file));
}
});
options.content = (options.sassMap) ? '$' + options.sassMapName + ': (\n' + options.content + ');' : options.content;

@@ -36,0 +57,0 @@ fs.writeFile(options.dest, options.content, function(err, data) {

2

package.json
{
"name": "files-to-sass",
"version": "0.2.1",
"version": "0.2.3",
"description": "Converts a list of files to (a map of) Sass variables with their content.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,2 +23,4 @@ # Files to Sass

dest: '/path/to/dest/file.scss',
useSassMap: true, // default is false
sassMapName: 'MyFiles', // defaults to: 'fileMap'
debug: true

@@ -37,2 +39,4 @@ });

dest: '/path/to/dest/file.scss',
useSassMap: true,
sassMapName: 'MyFiles',
debug: true

@@ -51,2 +55,11 @@ });

With SassMap:
```
$fileMap: (
logo: '<svg width="58" height="56" viewBox="0 0 58 56"><g fill="#163962"...';
icon-download: '<svg width="12" height="12" viewBox="0 0 12 12"><g fill="#000"...';
icon-arrow-right: '<svg width="15" height="15" viewBox="0 0 15 15"><g fill="#fd0"...';
);
```
#### Options

@@ -63,6 +76,11 @@

##### options.useSassMap
Optional. Set to true if you want to output a Sass map.
##### options.sassMapName
Optional. String to be used as the Sass map variable name. The `$` will be prepended.
### Todo
* Add ability to use files as source input.
* Add option to use maps in stead of plain variables.
* ~~Add option to use maps in stead of plain variables.~~ Thanks @sebsmi
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc