Skip to content

Commit

Permalink
Update replace.js
Browse files Browse the repository at this point in the history
If you do not mind, I would like to suggest you make the following changes. So that we could not only observe the result in the console but also process this data if necessary
  • Loading branch information
Dwarfess authored Jan 1, 2020
1 parent e4778d7 commit 4045141
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var fs = require("fs"),
sharedOptions = require("./bin/shared-options");

module.exports = function(options) {
var matched = [];
// If the path is the same as the default and the recursive option was not
// specified, search recursively under the current directory as a
// convenience.
Expand Down Expand Up @@ -81,6 +82,7 @@ module.exports = function(options) {
}
}

return matched;

function canSearch(file, isFile) {
var inIncludes = includes && includes.some(function(include) {
Expand Down Expand Up @@ -151,6 +153,11 @@ module.exports = function(options) {
if (canReplace && text !== null) {
fs.writeFileSync(file, text);
}

matched.push({
file,
text
});
}
else if (stats.isDirectory() && options.recursive) {
var files = fs.readdirSync(file);
Expand Down

0 comments on commit 4045141

Please sign in to comment.