Code Monkey home page Code Monkey logo

Comments (2)

fudom avatar fudom commented on June 20, 2024

I found the following:

const getFileOpts: Flags = {
create: !options.append,
exclusive: !options.replace,
};

export interface Flags {
/**
* Used to indicate that the user wants to create a file or directory if it was not previously there.
*/
create?: boolean;
/**
* By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the
* target path already exists.
*/
exclusive?: boolean;
}

Original source of the plugin:

create - file or directory if it doesn't exist
exclusive - used with create; if true the command will fail if target path exists

Following the code of this repo further to writeFileEntry. This means. You don't need replace here, just append. The option replace will just throw an error if the file already exist. But please correct me if I'm wrong. In my case:

log(message, replace = false) {
  this.file.writeFile(path, fileName, message, { append: !replace, replace: true } );
}

But this does not work as expected. There is no option combination to log append or not to a file regardless if existing or not. You either get an error if the file already exists or get an error if the file does not already exists. It's a mess! With append true and replace true I get an error, when the file does not exist. Yes, because create = !append. But this forces me to know, if the file already exists or not. It's really not good implemented. The following does also not work.

const fileExists = await this.file.checkFile(path, fileName);
await this.file.writeFile(path, fileName, message, { append: fileExists });

I mean in background is create = !append. Means if fileExists == true, then create = false. And replace (exclusive behind) has no effect, when create == false. It should just open the file and log. If fileExists == false, then create = true, but fails on it and throws error file not exists NOT_FOUND_ERR. Regardless of replace. Any idea?

Update: checkFile does not work. It rejects instead of resolve boolean. Ref. #4689 So there are really some lacks in types, docs and code.

from awesome-cordova-plugins.

github-actions avatar github-actions commented on June 20, 2024

There has been no recent activity and this issue has been marked inactive.

from awesome-cordova-plugins.

Related Issues (20)

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.