Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@songkick/replaceinfiles
Advanced tools
Utility to replace a map of strings in many files
Use cases:
hashmark
to replace references to hashmarked files - see exampleInstall
npm i replaceinfiles
Create or generate a replace map, save in a file or pipe to stdin
{
"foo": "bar",
"hello": "goodbye",
"world": "earth",
"%API_URL%": "https://myservice.com/api"
}
Run
Usage: replaceinfiles [options]
Options:
-h, --help output usage information
-V, --version output the version number
-s, --source <glob> glob matching files to be updated
-d, --dest-pattern <path> pattern to output files
-o, --output-path <path> path to output report file default: stdout
-S, --silent do not output report
-r, --replace-map-path <path> path to replace map json, default: stdin
-e, --encoding <string> used for both read and write, default "utf-8"
Examples
Streaming replace map from stdin
cat replace-map.json | replaceinfiles -s src/*.css -d 'dist/{base}'
Getting replace map from file
replaceinfiles -r replace-map.json -s src/*.css -d 'dist/{base}'
Write report to a file
replaceinfiles -r replace-map.json -s src/*.css -d 'dist/{base}' > report.json
# or
replaceinfiles -r replace-map.json -s src/*.css -d 'dist/{base}' -o report.json
replaceinfiles
generates a report on stdout
or specified path for you to pipe other tools if you need to.
Here is an example:
{
"options": {
"source": "test/src/*.txt",
"destPattern": "test/dist/{base}",
"outputPath": null,
"replaceMapPath": null,
"replaceMap": {
"hello": "goodbye",
"world": "earth"
},
"encoding": "utf-8"
},
"result": [
{
"src": "test/src/one.txt",
"dest": "test/dist/one.txt",
"changed": true
},
{
"src": "test/src/three.txt",
"dest": "test/dist/three.txt",
"changed": false
},
{
"src": "test/src/two.txt",
"dest": "test/dist/two.txt",
"changed": true
}
]
}
-s, --source: A glob matching the files you want to replace from
-d, --dest-pattern: A pattern to define updated files destination. You can use all the path.parse()
result values (root, dir, name, base, ext
), example: -d './dist/{dir}/{name}.build{ext}'
-r, --replace-map-path: Path to a replace map JSON file ({'stringToReplace': 'replaceWithThat', '..', '...'}
). stdin
is used as default.
-o, --output-path: A path to write the report, default is stdout
-S, --silent: Do not output report, bypasses -o
-e, --encoding: Used for both read and write, default: utf-8
You can also run replaceinfiles
from node.
var replaceinfiles = require('replaceinfiles');
var options = {
source: './test/*.txt',
destPattern: './test/dist/{base}',
replaceMap: {
foo: 'bar'
}
};
replaceinfiles(options)
.then(function(report){
// ...
})
.catch(function(error) {
// ...
});
FAQs
Utility to replace a map of strings in many files
The npm package @songkick/replaceinfiles receives a total of 23 weekly downloads. As such, @songkick/replaceinfiles popularity was classified as not popular.
We found that @songkick/replaceinfiles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.