Skip to content

RFC: Dry runs and atomic tasks #323

Open
@zonzujiro

Description

@zonzujiro

Hey, guys!

While working on generator I have faced two issues, which I want try to solve and I want to hear your opinion.

In general, it would be great to solve them only in my project, just to avoid situation where I can brake something in widely used util. :) But if this is not possible and you don't mind, I can try to provide couple features to node-plop.

Problems

  1. When node-plop will run his list of actions and something will happen in the middle of modifications, it will throw error, we will have half-finished task and broken result.
  2. During a development of the commands, we need to re-run generator and then remove generated files, which is annoying.

Possible solution

For both cases we can try to use some in-memory fs instead of real fs first, like memory-fs of memfs.

General logic can look like this:

  1. Create copy of targetDir in memory
  2. Run actions
  3. In the end of operations copy result of all operations to real file system - replace files, like an idea.

Pros:
When something happens during running of tasks actual file system will stay the same and dry run will be also possible.

Cons:
I have never worked with above mentioned NPM packages and I am not sure, that they will cover all things node-plop needs. So probably if I will implement this feature in node-plop, it should be under the the --atomic probably :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions