New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

gulp-insert-lines

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-insert-lines

A gulp plugin that will insert a given line before or after the matches of the given regex filter.

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
94
-46.59%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-insert-lines

A gulp plugin that will insert a given line before or after the matches of the given regex filter.

Install

Install with npm

npm install --save-dev gulp-insert-lines

Examples

Our index.html file:

<!doctype html>
<html>
<head>
  <title>Our App</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="format-detection" content="telephone=no" />
</head>
<body ng-controller="AppController">
  <div>
      markup goes here...
  </div>
  <script type="text/javascript">
    angular.bootstrap(document, ['ourApp']);
  </script>
</body>
</html>

Example 1: Inserts a script tag at the end of index.html

var gulp = require('gulp');
var insertLines = require('gulp-insert-lines');

gulp.task('insert-scripts-bundle', function () {
  gulp.src('./build/index.html')
  .pipe(insertLines({
       'before': /<script\s+type=["']text\/javascript["']>\s*$/i,
      'lineBefore': '<script type="text/javascript" src="bundled.min.js"></script>'
    }))
  .pipe(gulp.dest('dist'));
});

Example 2: Inserts a styles tag at the beginning of index.html, Version 1

var gulp = require('gulp');
var insertLines = require('gulp-insert-lines');

gulp.task('insert-styles-bundle', function () {
  gulp.src('./build/index.html')
  .pipe(insertLines({
      'before': /<\/head>$/,
      'lineBefore': '<link rel="stylesheet" type="text/css" href="build/bundled.min.css" />'
    }))
  .pipe(gulp.dest('dist'));
});

Example 3: Inserts a styles tag at the beginning of index.html, Version 2

var gulp = require('gulp');
var insertLines = require('gulp-insert-lines');

gulp.task('insert-styles-bundle', function () {
  gulp.src('./build/index.html')
  .pipe(insertLines({
      'after': /<meta name=["#]format-detection["']\s+content=["']telephone=no["']\s+/>$/,
      'lineAfter': '<link rel="stylesheet" type="text/css" href="build/bundled.min.css" />'
    }))
  .pipe(gulp.dest('dist'));
});

License

MIT © Carsten Schaefer

Keywords

gulp

FAQs

Package last updated on 22 Feb 2015

Did you know?

Socket

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.

Install

Related posts