adamreisnz / replace-in-file

A simple utility to quickly replace contents in one or more files
580 stars 65 forks source link

CLI not changing files #126

Closed SteveEdson closed 3 years ago

SteveEdson commented 4 years ago

If I run the following:

replace-in-file "/ASSET_PATH" 'https://example.com' 'dist/**'

I get the output:

Replacing '/ASSET_PATH' with 'https://example.com'
483 file(s) were changed

I can then run it immediately afterwards and get the exact same output

Replacing '/ASSET_PATH' with 'https://example.com'
483 file(s) were changed

It seems to find the content fine, but it's not actually saving it back.

$ replace-in-file --version
6.1.0
SteveEdson commented 4 years ago

Putting the following on line 31 of cli.js:

  console.log('options', options);
  process.exit(1);

Results in:

options {
  ignore: [],
  encoding: 'utf-8',
  disableGlobs: false,
  allowEmptyPaths: undefined,
  countMatches: false,
  isRegex: false,
  verbose: false,
  quiet: false,
  dry: true,
  glob: {},
  cwd: null,
  from: '/ASSET_PATH',
  to: 'https://example.com',
  files: [ 'dist/**' ]
}

With dry: true. Guessing this is why isn't not updating. Tried adding --dry=false --dry false etc, but no luck

adamreisnz commented 4 years ago

Hi sorry for the late reply. Have you resolved this issue since? If not, can you please produce a standalone reproducible example?

adamreisnz commented 3 years ago

I think you must have had a configuration file sitting in your directory which was being used and had dry set to true, or have some other environmental issue causing argv.dry to be set to a non-falsey value somehow.

Assume you have since sorted it out!