Skip to content

Commit 310d37b

Browse files
committed
Fix CLI path resolving for absolute paths
1 parent 24ce4a6 commit 310d37b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,20 @@ replace-in-file from to some/file.js,some/**/glob.js
223223

224224
Multiple files or globs can be replaced by providing a comma separated list.
225225

226-
The flags `disableGlobs`, `ignore` and `encoding` are supported in the CLI.
226+
The flags `--disableGlobs`, `--ignore` and `--encoding` are supported in the CLI.
227227

228-
The flag `allowEmptyPaths` is not supported in the CLI as the replacement is
229-
synchronous, and the flag is only relevant for asynchronous replacement.
228+
The setting `allowEmptyPaths` is not supported in the CLI as the replacement is
229+
synchronous, and this setting is only relevant for asynchronous replacement.
230230

231-
To list the changed files, use the `verbose` flag.
231+
To list the changed files, use the `--verbose` flag.
232232

233233
A regular expression may be used for the `from` parameter by specifying the `--isRegex` flag.
234234

235+
The `from` and `to` parameters, as well as the files list, can be omitted if you provide this
236+
information in a configuration file. You can provide a path to a configuration file
237+
(either Javascript or JSON) with the `--configFile` flag. This path will be resolved using
238+
Node’s built in `path.resolve()`, so you can pass in an absolute or relative path.
239+
235240
## Version information
236241
From version 3.0.0 onwards, replace in file requires Node 6 or higher. If you need support for Node 4 or 5, use version 2.x.x.
237242

lib/helpers/load-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module.exports = function loadConfig(file) {
1515
return {};
1616
}
1717

18-
//Combine with CWD
19-
file = path.join(process.cwd(), file);
18+
//Resolve path
19+
file = path.resolve(file);
2020

2121
//Try to load
2222
return require(file);

0 commit comments

Comments
 (0)