yeoman / environment

Yeoman runtime environment
BSD 2-Clause "Simplified" License
128 stars 70 forks source link

Copy error when trying to run a generator in the same environment twice #82

Closed mwebler closed 4 years ago

mwebler commented 7 years ago

Hello there,

I'm not sure if this is supposed to work like this or if this is an error. But, when you call the same environment to run a generator again, it causes an assertion error for copy and copyTpl with glob patterns:

AssertionError: Trying to copy from a source that does not exist: envir-test/node_modules/generator-generator/subgenerator/templates/templates/**

Example :

const yeoman = require('yeoman-environment');
const env = yeoman.createEnv();

env.lookup(() => {
  env.run('generator', {'skip-install': true}, err => {
    console.log('done');
    env.run('generator', {'skip-install': true}, err => {
        console.log('done');
    });
  });
});

Everything works fine if I create a new environment each time I execute the generator.

Versions:

SBoudrias commented 7 years ago

Do you have the generator code?

mwebler commented 7 years ago

The error occurs using any generator which uses glob patterns in copy calls.

In the example above I'm running the generator-generator v3.1.0.

--EDIT-- To be more specific, just create an app following this gist, It tries to run twice the generator-generator.

rgroothuijsen commented 6 years ago

From what I can see by debugging the copy function, it adds files that were previously requested to an in-memory store, and somewhere along the way the globbed path is added to the list. On subsequent calls, it then mistakenly treats this as a literal path.

Edit: I think I found the issue. It's not what I'd expect to happen, but it happens when the code checks if a file path exists. At this point, mem-fs wrongly adds the invalid path entry to its store.

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days