npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mfonseca/gulp-replacer

v1.0.0-alpha.2

Published

Gulp plugin that replaces properties on text files, much like apache ant's filtering tool.

Downloads

12

Readme

gulp-replacer

Gulp plugin that replaces properties on text files, much like apache ant's filtering tool.

Usage

First, install the plugin as a dev dependency:

    npm install --save-dev gulp-replacer

Then you can start using it, as follows:

    const replacer = require("gulp-replacer");

    gulp.task('replace', function () {
        gulp.src(['src/**/*.js'])
            .pipe(replacer.replaceProps({ prop1: "Test prop", prop2: "Another test prop" }))
            .pipe(gulp.dest('build/'));
    });

This example will replace every ocurrency of #[[prop1]] and #[[prop2]] on every javascript file in the src folder for their respective values.

API

replaceProps(properties[, options])

properties (Plain object)

The object containing the properties to be searched and replaced.

Bellow we have a list of properties provided by default, that is added to your given properties set. You still can override any of these.

current.date            // string date value
current.time            // string time value
current.datetime        // string datetime value
current.timestamp       // string timestamp value
current.month           // integer month value
current.monthname       // string month name value
current.year            // integer year value

options (Plain object)

An argument that configures the replacing proccess options.

The defaults are as follows:

{
    enabled: true,
    startDelimiter: "#[[",
    endDelimiter: "]]",
    dateFormat: "dd/mm/yyyy",
    timeFormat: "hh:MM:ss",
    datetimeFormat: "dd/mm/yyyy hh:MM:ss",
    timestampFormat: "yyyy_mm_dd-hh_MM_ss",
    logLevel: LOG_INFO
}

enabled (Boolean. Defaults to true)

Can be used to enable/disable the replacement proccessing dynamically.

startDelimiter and endDelimiter (String. Defaults to "#[[" and "]]", respectivelly)

These are the delimiters of a propertie that must be proccessed by the gulp-replacer in your sourcecodes.

If you give a properties value of:

{
    prop1: "Test prop",
    prop2: "Another test prop",
};

and leave the default delimiters, the plugin will search and replace each and all occurences of #[[prop1]] and #[[prop2]] in your provided sources with their respective values.

You can even create properties that references other properties!

{
    prop1: "Hello #[[prop2]]",
    prop2: "World!",
};

If a given prop usage in your source doesn't have a respective key/value in your properties, the usage will be unnafected.

dateFormat (String. Defaults to "dd/mm/yyyy")

Pattern used to format the provided property current.date.

See the dateformat module for instructions about the valid patterns.

timeFormat (String. Defaults to "hh:MM:ss")

Pattern used to format the provided property CURRENT_TIME.

See the dateformat module for instructions about the valid patterns.

datetimeFormat (String. Defaults to "dd/mm/yyyy hh:MM:ss")

Pattern used to format the provided property current.datetime.

See the dateformat module for instructions about the valid patterns.

timestampFormat (String. Defaults to "yyyy_mm_dd-hh_MM_ss")

Pattern used to format the provided property current.timestamp.

See the dateformat module for instructions about the valid patterns.

logLevel (Integer. Defaults to 2)

Controls how much logging verbose you want to see on the console.

The possible values are:

10  // LOG_ALL
 8  // LOG_DEBUG;
 3  // LOG_INFO;
 2  // LOG_WARNING
 1  // LOG_SEVERE
 0  // LOG_NONE