replacestuff
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

replacestuff

Build Status npm version

npm

Replaces strings in files. Useful creating a npm only build pipeline. Inspired by https://github.com/harthur/replace .

Strings can be replaced by other strings, environment variables and the current git version hash (SHA).

Does not follow symlinks.

Installing

npm install -g replacestuff

Using

To see all options

replacestuff --help

In-place replace:

replacestuff s1 s2 dist/**/*.html

Different output folder

replacestuff s1 s2 **/* --basedir=build --output=dist/

With replacestuff.json configuration

If there are several strings to replace, it's better to use a replacestuff.json file.

[
    { search: 'search0', replace: 'replace0' },
    { searchRegExp: 'search1', replace: 'replace1' },
    { search: 'search2', replaceVar: 'gitsha' },
    { search: 'search3', replaceEnv: 'replace3' }
]

In this example

  • the string 'search' will be replaced by 'replace0'.
  • strings matching the regular expression 'search1' will be replaced by 'replace1'.
  • the string 'search2' will be replaced by the current git version hash.
  • the string 'search3' will be replaced by the value of the environment variable 'replace3'.

Keep in mind that each replacement happens in the same order as in the replacestuff.json.

Test

npm test

Develop

npm run dev:watch

Update version

npm version major|minor|patch
npm publish
git push

Tslint

rules

License

Copyright (c) 2016 Wouter Mooij.

Licensed under the MIT License.

Package Sidebar

Install

npm i replacestuff

Weekly Downloads

0

Version

0.0.8

License

MIT

Last publish

Collaborators

  • wwwouter