howardroark / pollinate

Template your base files and generate new projects from Git(Hub).
The Unlicense
225 stars 16 forks source link

Does not automatically create nested folders in `move` #20

Closed Grinderofl closed 8 years ago

Grinderofl commented 8 years ago

This is my move section:

{"Production\\ProsperoTemplate\\src\\ProsperoTemplate\\ProsperoTemplate.Web.xproj":"Production\\ProsperoTemplate\\src\\ProsperoTemplate\\{{ name }}.Web.xproj"},
{"Production\\ProsperoTemplate\\src\\ProsperoTemplate.Core\\ProsperoTemplate.Core.xproj":"Production\\ProsperoTemplate\\src\\ProsperoTemplate.Core\\{{ name }}.xproj"},

{"Production\\ProsperoTemplate\\ProsperoTemplate.sln":"Production\\ProsperoTemplate\\{{ name }}.sln"},

{"Production\\ProsperoTemplate\\src\\ProsperoTemplate\\":"Production\\ProsperoTemplate\\src\\{{ name }}\\"},
{"Production\\ProsperoTemplate\\src\\ProsperoTemplate.Core\\":"Production\\ProsperoTemplate\\src\\{{ name }}.Core\\"},

{"Production\\ProsperoTemplate\\":"Production\\{{ name }}\\"}

I have structure like this:

Production\ProsperoTemplate\src\ProsperoTemplate\
Production\ProsperoTemplate\src\ProsperoTemplate.Core\

When running the command pollinate ./ProsperoTemplate --name=Sample

I expect the structure to end up:

Production\Sample\src\Sample\
Production\Sample\src\Sample.Core\

However, when running once, I get:

Production\ProsperoTemplate\Sample\
Production\ProsperoTemplate\Sample.Core\

I delete entire Sample\ directory and rerun the command, and end up with

Production\Sample\src\Sample\
Production\Sample\src\ProsperoTemplate.Core\

I suspect there's a concurrency issue somewhere, although I can't tell why just by looking at the source, seems a fairly standard synchronous loop, so I assume the mv is non-blocking...

howardroark commented 8 years ago

Hey! So I have to be 100% honest... this is my first node project :P I am used to Python... which is 100% synchronous and fails fast. Node is neither, so I may not have set things up well for debugging.

Maybe you could put a simple case that fails this way onto GitHub?

howardroark commented 8 years ago

@Grinderofl I just looked at the code again... It definitely does not do what it is meant to do, whoops! It basically moves everything into it's final location after the first item in that array is accomplished.

Will need to use the node tool async to build a "series" of mv callback actions and then let them run in a sequence.

howardroark commented 8 years ago

I fixed a bunch of issues... https://github.com/everysquare/pollinate/commit/4f02011873cb563d884de412823fa1fd990de5f4

Though mv itself will error if you trying to move something to a path where a subdirectory does not yet exist. At least it errors now!

Nesting will need more thinking

howardroark commented 8 years ago

I think it will need to do something like run mkdirp for each path (minus the file). Then try to run mv. Maybe need a good regex for this.

howardroark commented 8 years ago

@Grinderofl I think this should work for you now with 0.0.45 ... https://github.com/everysquare/pollinate/commit/8e1c4ac410f257059152616455c0a74495fc9c41