SBoudrias / mem-fs-editor

File edition helpers working on top of mem-fs (https://github.com/SBoudrias/mem-fs)
MIT License
415 stars 47 forks source link

There had different performance in debugging and formal environment. #70

Open hugojing opened 7 years ago

hugojing commented 7 years ago

yeoman-generator is dependent on this package.

When I written this code in debugging environment:

writing: function () {
    this.fs.copy(
      this.templatePath('*'),
      this.destinationPath('*')
    );
    this.fs.copy(
      this.templatePath('.babelrc'),
      this.destinationPath('.babelrc')
    );
   this.fs.copy(
      this.templatePath('.npmrc'),
      this.destinationPath('.npmrc')
    );
    this.fs.copy(
      this.templatePath('.gitignore'),
      this.destinationPath('.gitignore')
    );
    this.fs.copy(
      this.templatePath('src'),
      this.destinationPath('src')
    );
 },

I run

$ node --debug `which yo` webpack-babel

and it's OK.

I published, used in formal environment, then errored:

events.js:160
      throw er; // Unhandled 'error' event
      ^
AssertionError: When copying multiple files, provide a directory as destination
    at EditionInterface.exports.copy (/usr/local/lib/node_modules/generator-webpack-babel/node_modules/mem-fs-editor/lib/actions/copy.js:34:5)
    at child.writing (/usr/local/lib/node_modules/generator-webpack-babel/app/index.js:31:13)
    at Object.<anonymous> (/usr/local/lib/node_modules/generator-webpack-babel/node_modules/yeoman-generator/lib/index.js:417:23)
    at /usr/local/lib/node_modules/generator-webpack-babel/node_modules/run-async/index.js:25:25
    at /usr/local/lib/node_modules/generator-webpack-babel/node_modules/run-async/index.js:24:19
    at /usr/local/lib/node_modules/generator-webpack-babel/node_modules/yeoman-generator/lib/index.js:418:9
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)

When I modified code like this:

writing: function () {
    this.fs.copy(
      this.templatePath('*'),
      this.destinationRoot(),
      { globOptions: { dot: true } }
    );
    this.fs.copy(
      this.templatePath('src'),
      this.destinationPath('src')
    );
  },

It's just OK now.

Why it had different performance? Thanks.

SBoudrias commented 7 years ago

Looks like it just didn't use the same dependency version. If you update your packages locally, it'll act like the latest test.

hugojing commented 7 years ago

Had same version: mem-fs-editor 3.0.2....

ㄟ( ▔, ▔ )ㄏ