PATH:
usr
/
local
/
lib
/
node_modules
/
ghost-cli
/
node_modules
/
replace-in-file
/
lib
/
helpers
'use strict'; /** * Dependencies */ const fs = require('fs'); const makeReplacements = require('./make-replacements'); /** * Helper to replace in a single file (sync) */ module.exports = function replaceSync(file, from, to, config) { //Extract relevant config and read file contents const {encoding, dry, countMatches} = config; const contents = fs.readFileSync(file, encoding); //Replace contents and check if anything changed const [result, newContents] = makeReplacements( contents, from, to, file, countMatches ); //Contents changed and not a dry run? Write to file if (result.hasChanged && !dry) { fs.writeFileSync(file, newContents, encoding); } //Return result return result; };
[-] success-handler.js
[edit]
[-] replace-sync.js
[edit]
[+]
..
[-] error-handler.js
[edit]
[-] make-replacements.js
[edit]
[-] parse-config.js
[edit]
[-] combine-config.js
[edit]
[-] get-paths-sync.js
[edit]
[-] replace-async.js
[edit]
[-] load-config.js
[edit]
[-] glob-async.js
[edit]
[-] get-paths-async.js
[edit]