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.
metalsmith-transform
Advanced tools
Transform or manipulate file objects in the metalsmith pipeline
Transform or manipulate file objects in the metalsmith pipeline
metalsmith-transform
is a metalsmith plugin which allows the use of custom functions to manipulate the file object in a metalsmith pipeline.
Furthermore, instead of writing a full plugin, you can just pass in the transformation function into this instead.
String methods are inspired by gulp-insert.
$ npm install metalsmith-transform
or
$ yarn add metalsmith-transform
import transform from 'metalsmith-transform';
You can pass in an object or a function as an argument. i.e.
metalsmith.use(transform(function(fileObject, metalsmithData) {
return fileObject;
}));
// or
metalsmith.use(transform({
action: '', // append / prepend / wrap / transform
value: '', // string | function (only if using transform)
pattern: '*.md'
}));
"plugins": {
"metalsmith-transform": {
"action": "append",
"value": "Include Me!"
}
}
Note on CLI Usage: Since JSON does not take functions, only append
, prepend
and wrap
actions are accepted.
By default, if an action is not defined, append
is used.
In the examples below, assume that the content in your files are "I am".
Calls a function with the file
object and metalsmith
instance.
Function should return the modified contents of the file.
metalsmith.use(transform(function(data, m){
let contents = data.contents.toString().toUpperCase();
data.contents = new Buffer(contents);
return data;
}));
// result: I AM
Appends a string onto the contents.
// Appends 'world' to the content of every file
metalsmith.use(transform({
action: 'append',
value: 'world'
}));
// result: I am world
Prepends a string onto the contents.
// Prepends 'Hello' to the content of every file
metalsmith.use(transform({
action: 'prepend',
value: 'hello'
}));
// result: hello I am
Wraps the contents with two strings.
// prepends 'hello' and appends 'world' to the content of every file
metalsmith.use(transform({
action: 'wrap',
value: ['hello', 'world']
}));
// result: hello I am world
metalsmith-transform
is MIT licensed
FAQs
Transform or manipulate file objects in the metalsmith pipeline
The npm package metalsmith-transform receives a total of 9 weekly downloads. As such, metalsmith-transform popularity was classified as not popular.
We found that metalsmith-transform 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.