Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
gulp-replace-task
Advanced tools
Replace text patterns with applause.
From NPM:
npm install gulp-replace-task --save-dev
Assuming installation via NPM, you can use gulp-replace-task
in your gulpfile like this:
var gulp = require('gulp');
var replace = require('gulp-replace-task');
gulp.task('default', function () {
gulp
.src('src/index.html')
.pipe(
replace({
patterns: [
{
match: 'foo',
replacement: 'bar'
}
]
})
)
.pipe(gulp.dest('build'));
});
Supports all the applause options.
File src/manifest.appcache
:
CACHE MANIFEST
# @@timestamp
CACHE:
favicon.ico
index.html
NETWORK:
*
Gulpfile:
var gulp = require('gulp');
var replace = require('gulp-replace-task');
gulp.task('default', function () {
gulp
.src('src/manifest.appcache')
.pipe(
replace({
patterns: [
{
match: 'timestamp',
replacement: Date.now()
}
]
})
)
.pipe(gulp.dest('build'));
});
File src/manifest.appcache
:
CACHE MANIFEST
# @@timestamp
CACHE:
favicon.ico
index.html
NETWORK:
*
File src/humans.txt
:
__ _
_ _/__ /./|,//_`
/_//_// /_|/// //_, outaTiME v.@@version
/* TEAM */
Web Developer / Graphic Designer: Ariel Oscar Falduto
Site: https://www.outa.im
Twitter: @outa7iME
Contact: afalduto at gmail dot com
From: Buenos Aires, Argentina
/* SITE */
Last update: @@timestamp
Standards: HTML5, CSS3, robotstxt.org, humanstxt.org
Components: H5BP, Modernizr, jQuery, Bootstrap, LESS, Jade, Grunt
Software: Sublime Text, Photoshop, LiveReload
Gulpfile:
var gulp = require('gulp');
var replace = require('gulp-replace-task');
var pkg = require('./package.json');
gulp.task('default', function () {
gulp
.src(['src/manifest.appcache', 'src/humans.txt'])
.pipe(
replace({
patterns: [
{
match: 'version',
replacement: pkg.version
},
{
match: 'timestamp',
replacement: Date.now()
}
]
})
)
.pipe(gulp.dest('build'));
});
File src/index.html
:
<head>
<link rel="stylesheet" href="/css/style.css?rel=@@timestamp">
<script src="/js/app.js?rel=@@timestamp"></script>
</head>
Gulpfile:
var gulp = require('gulp');
var replace = require('gulp-replace-task');
gulp.task('default', function () {
gulp
.src('src/index.html')
.pipe(
replace({
patterns: [
{
match: 'timestamp',
replacement: Date.now()
}
]
})
)
.pipe(gulp.dest('build'));
});
File src/index.html
:
<body>
@@include
</body>
Gulpfile:
var gulp = require('gulp');
var replace = require('gulp-replace-task');
var fs = require('fs');
gulp.task('default', function () {
gulp
.src('src/index.html')
.pipe(
replace({
patterns: [
{
match: 'include',
replacement: fs.readFileSync('./includes/content.html', 'utf8')
}
]
})
)
.pipe(gulp.dest('build'));
});
File src/username.txt
:
John Smith
Gulpfile:
var gulp = require('gulp');
var replace = require('gulp-replace-task');
gulp.task('default', function () {
gulp
.src('src/username.txt')
.pipe(
replace({
patterns: [
{
match: /(\w+)\s(\w+)/,
replacement: '$2, $1' // Replaces "John Smith" with "Smith, John"
}
]
})
)
.pipe(gulp.dest('build'));
});
foo
instead of @@foo
Gulpfile:
var gulp = require('gulp');
var replace = require('gulp-replace-task');
gulp.task('default', function () {
gulp
.src('src/foo.txt')
.pipe(
replace({
patterns: [
{
match: /foo/g, // Explicitly using a regexp
replacement: 'bar'
}
]
})
)
.pipe(
replace({
patterns: [
{
match: 'foo',
replacement: 'bar'
}
],
usePrefix: false // Using the option provided
})
)
.pipe(
replace({
patterns: [
{
match: 'foo',
replacement: 'bar'
}
],
prefix: '' // Removing the prefix manually
})
)
.pipe(gulp.dest('build'));
});
MIT © outaTiME
FAQs
Replace text patterns with applause.
The npm package gulp-replace-task receives a total of 10,248 weekly downloads. As such, gulp-replace-task popularity was classified as popular.
We found that gulp-replace-task 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.