Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
gulp-file-contents-to-keys
Advanced tools
convert files into key/value objects where key is filename, value is the content
Input some files, outputs a javascript Object with keys as file names and values as their content (escaped string) Very helpful when working with HTML template files and you want to import them all in an easy way.
See my other related packaged:
Compiles templates files (lodash/underscore) to ES6 exports, in a single file
Input template files, output a single file with exports as variables (file name) and values as file contents.
$ npm install gulp-file-contents-to-keys
Given a nested directory of files like so,
my-files
├── a.html
├── a.html
└── some folder-c
└── c.html
gulp-file-contents-to-keys
reads each file, and outputs a single file representing the contents of each file.
The output is an Object (keys/values) and can have a configurable varable name.
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>"
};
var gulp = require('gulp');
var filesTokeys = require('gulp-file-contents-to-keys');
gulp.task('default', function() {
gulp.src('./templates/**/*.html')
.pipe(filesTokeys(
{
name : 'export default templates',
fileName : 'output.js',
minify : true,
removeFileTypes : true,
folderDelimiter : '|',
}
))
.pipe(gulp.dest('./test/output'))
});
Name | Type | Default | Info |
---|---|---|---|
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 | |
minify | Boolean | true | minify the files' content (removes new lines & whitespaces between HTML tags) |
removeFileTypes | Boolean | true | don't include in the Objects keys the file types (disregard .html for example) |
FAQs
convert files into key/value objects where key is filename, value is the content
The npm package gulp-file-contents-to-keys receives a total of 1 weekly downloads. As such, gulp-file-contents-to-keys popularity was classified as not popular.
We found that gulp-file-contents-to-keys demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.