New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-file-contents-to-keys

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-file-contents-to-keys - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

3

gulpfile.js

@@ -12,4 +12,3 @@ var gulp = require('gulp');

minify : true,
removeFileTypes : true,
folderDelimiter : '|',
removeFileTypes : true
}

@@ -16,0 +15,0 @@ ))

@@ -11,3 +11,3 @@ // by Yair-Even-Or

var PLUGIN_NAME = 'gulp-file-contents-to-keys',
files = { },
files = {},
outputFile = null,

@@ -22,4 +22,3 @@ options = {

function parseFileName( file ){
var name = file.path.replace(file.base, '');//.replace(/\\/g,'__').replace(/-/g,'_'); // 'foo/bar/baz-meh.txt' => 'foo__bar__baz_meh'
name = name.replace(/\\/g, options.folderDelimiter); // folders delimeter "|"
var name = file.path.replace(file.base, '');

@@ -47,4 +46,17 @@ if( options.removeFileTypes )

outputFile = outputFile || file;
var filePath = parseFileName(file); // path.relative(file.base, file.path);
files[filePath] = parseFileContent(file);
var fileName = parseFileName(file),
path = files; // path.relative(file.base, file.path);
filePathArr = fileName.split('\\');
filePathArr.forEach((v, i) => {
// last part is the file name itself and not a path
if( i == filePathArr.length - 1 )
path[v] = parseFileContent(file);
else if( v in path )
path = path[v];
else
path = path[v] = {};
})
callback();

@@ -64,3 +76,3 @@ }

outputFile.contents = new Buffer(
options.name + ' = ' + JSON.stringify(files, null, 2) + ';'
options.name + ' = ' + JSON.stringify(files, null, 4) + ';'
);

@@ -67,0 +79,0 @@

{
"version" : "1.0.2",
"version" : "2.0.0",
"name" : "gulp-file-contents-to-keys",

@@ -18,10 +18,9 @@ "description" : "convert files into key/value objects where key is filename, value is the content",

"dependencies": {
"gulp-util" : "~3.0.1",
"nconf" : "~0.6.9",
"through2" : "~0.6.1",
"path" : "~0.12.7",
"vinyl" : "~0.6.1"
"gulp-util" : "~3.0.8",
"through2" : "~2.0.3",
"path" : "~0.12.7",
"vinyl" : "~2.0.2"
},
"devDependencies": {
"gulp" : "~3.8.7",
"gulp" : "~3.9.1",
"gulp-concat" : "~2.6.1",

@@ -28,0 +27,0 @@ "mocha" : "*"

@@ -33,3 +33,6 @@

└── some folder-c
└── c.html
├── c.html
└── deep
└── d.html
```

@@ -40,15 +43,5 @@

## Output example:
## How to Use (with GULP)
```javascript
var templates = {
"a": "<div>file a</div>",
"b": "<p style=\"color:red\">file b</p>",
"some folder-c|c": "<ul><li>item 1</li><li>item 2</li><li>item 3</li></ul>"
};
```
## How to Use
```javascript
var gulp = require('gulp');

@@ -72,2 +65,17 @@ var filesTokeys = require('gulp-file-contents-to-keys');

## Output example:
```javascript
export default templates = {
"a": "<div>file a</div>",
"b": "<p style=\"color:red\">file b</p>",
"some folder-c": {
"c": "<ul><li>item 1</li><li>item 2</li><li>item 3</li></ul>",
"deep": {
"d": "<p>deepest</p>"
}
}
};
```
## Settings

@@ -78,3 +86,2 @@

name | String | `var temlpates` | the name which points to the created Object. For example: `export default templates` if you want to import it using ES6 modules
folderDelimiter | String | \| | delimiter in Object key, for deep files within folders
fileName | String | | example: 'output.js' will output that file to the stream. it is an optional and the output of the plugin can also be used (within the gulp task) with `gulp-concat` to output to anywhere

@@ -81,0 +88,0 @@ minify | Boolean | true | minify the files' content (removes new lines & whitespaces between HTML tags)

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