Giter Site home page Giter Site logo

Comments (2)

Xotic750 avatar Xotic750 commented on May 28, 2024

I'm afraid that I'm unable to reproduce this problem. Are you able to give me something more definitive that I can reproduce it with?

from replace-x.

marcosins avatar marcosins commented on May 28, 2024

I'm able to reproduce this. It looks like the script is taking the replacement string as one of the paths to look for files:

$ npm i replace-x
$ npx replace-x --version
1.7.2
$ echo 'this file has text'  > test.txt
$ cat test.txt 
this file has text
$ npx replace-x 'text' 'TEXT BUT UPPERCASE' test.txt
ENOENT: no such file or directory, lstat 'TEXT BUT UPPERCASE'

I was able to fix it by adding the replacement property to shared-options:

replacement: {
      position: 1, // Second argument
      string: true,
      describe: 'Replacement string for matches',
      demandOption: true,
}

At the same time, the paths property has a wrong index of 1 when it should be 2 (third argument):

position: 1,

It also looks like positionalArgs being an object is a problem for the parser that is looking for an array:

const $addlPosArgs = Array.isArray(addlPosArgs) ? addlPosArgs : [];

After those fixes, I was able to run the script successfully:

$ echo 'some random TEXT' > test.txt 
$ cat test.txt 
some random TEXT
$ npx replace-x 'TEXT' 'text, but lowercase' test.txt
test.txt
 1: some random text, but lowercase
$ cat test.txt 
some random text, but lowercase

I hope this helps you to publish a fix.

from replace-x.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.