Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to copy twice the same glob pattern #1110

Closed
alqh opened this issue May 28, 2019 · 6 comments
Closed

Error when trying to copy twice the same glob pattern #1110

alqh opened this issue May 28, 2019 · 6 comments

Comments

@alqh
Copy link

alqh commented May 28, 2019

Hi,

This is a similar issue with that reported in #1022 .
What I did was do two copy calls with the same glob to two different directories.

const types = ['icon', 'outline-icons'];
// To dist/themes
types.forEach((type) => {
this.fs.copy(
 this.destinationPath(./node_modules/mytheme/themes/**/${type}.*),
 this.destinationPath('./dist/themes/')
);
});

// REPEAT to anotherFolder/web
types.forEach((type) => {
this.fs.copy(
 this.destinationPath(./node_modules/mytheme/themes/**/${type}.*),
 this.destinationPath('./anotherFolder/web/')
);
});

I place a few console loggings around mem-fs-editor and also after the copy.

  • Log the diskfiles and storefiles variables in mem-fs-editor/lib/action/copy.js. Notice storefiles has nothing on the first copy.
  • Somehow after the copy is done, I logged the store again within the yeoman generator (this.fs.store) and found that the glob pattern has been added to the store
  • The next time it calls copy and mem-fs-editor/lib/action/copy.js tries to calculate the files, it picks up the the glob pattern in the store, which also multimatch the glob path to the glob path itself.
  • It calls copy single path with the glob path (thinking it's the real path for file) and spews that error that file does not exist - which is correct because a path of */icons. does not exist.
/*** FIRST mem-fs-editor/lib/action/copy.js icon.* to dist/themes **/
DISKFILES: C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.eot,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.otf,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.svg,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.ttf,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff2
STOREFILES:
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.eot
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.eot
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.otf
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.otf
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.svg
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.svg
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.ttf
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.ttf
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff2
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff2
C:\myapps\node_modules\mytheme\themes\**\icons.* done
// COPY DONE


/** FIRST mem-fs-editor/lib/action/copy.js outline-icons.* to dist/themes **/
DISKFILES: C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.eot,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.svg,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.ttf,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff2
STOREFILES:
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.eot
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.eot
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.svg
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.svg
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.ttf
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.ttf
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff2
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff2
C:\myapps\node_modules\mytheme\themes\**\outline-icons.* done
// COPY DONE

icons dist done == OUTPUT STORE AFTER COPY
### STORE NOW IS: C:\myapps\bower.json,C:\myapps\package.json,C:\myapps\.yo-rc.json,C:\Users\someuser\.yo-rc-global.json,C:\myapps\node_modules\mytheme\themes\**\icons.*,C:\myapps\dist\themes,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.eot,C:\myapps\dist\themes\default\assets\fonts\icons.eot,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.otf,C:\myapps\dist\themes\default\assets\fonts\icons.otf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.svg,C:\myapps\dist\themes\default\assets\fonts\icons.svg,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.ttf,C:\myapps\dist\themes\default\assets\fonts\icons.ttf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.woff,C:\myapps\dist\themes\default\assets\fonts\icons.woff,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.woff2,C:\myapps\dist\themes\default\assets\fonts\icons.woff2,C:\myapps\node_modules\mytheme\themes\**\outline-icons.*,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.eot,C:\myapps\dist\themes\default\assets\fonts\outline-icons.eot,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.svg,C:\myapps\dist\themes\default\assets\fonts\outline-icons.svg,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.ttf,C:\myapps\dist\themes\default\assets\fonts\outline-icons.ttf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.woff,C:\myapps\dist\themes\default\assets\fonts\outline-icons.woff,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.woff2,C:\myapps\dist\themes\default\assets\fonts\outline-icons.woff2

outline-icons dist done == OUTPUT STORE AFTER COPY
### STORE NOW IS: C:\myapps\bower.json,C:\myapps\package.json,C:\myapps\.yo-rc.json,C:\Users\someuser\.yo-rc-global.json,C:\myapps\node_modules\mytheme\themes\**\icons.*,C:\myapps\dist\themes,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.eot,C:\myapps\dist\themes\default\assets\fonts\icons.eot,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.otf,C:\myapps\dist\themes\default\assets\fonts\icons.otf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.svg,C:\myapps\dist\themes\default\assets\fonts\icons.svg,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.ttf,C:\myapps\dist\themes\default\assets\fonts\icons.ttf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.woff,C:\myapps\dist\themes\default\assets\fonts\icons.woff,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.woff2,C:\myapps\dist\themes\default\assets\fonts\icons.woff2,C:\myapps\node_modules\mytheme\themes\**\outline-icons.*,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.eot,C:\myapps\dist\themes\default\assets\fonts\outline-icons.eot,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.svg,C:\myapps\dist\themes\default\assets\fonts\outline-icons.svg,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.ttf,C:\myapps\dist\themes\default\assets\fonts\outline-icons.ttf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.woff,C:\myapps\dist\themes\default\assets\fonts\outline-icons.woff,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.woff2,C:\myapps\dist\themes\default\assets\fonts\outline-icons.woff2

/** SECOND mem-fs-editor/lib/action/copy.js icon.* to anotherFolder\web\ **/
Copying to OSGI application at C:\myapps\anotherFolder\web\
DISKFILES: C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.eot,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.otf,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.svg,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.ttf,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff2
STOREFILES: C:\myapps\node_modules\mytheme\themes\**\icons.*,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.eot,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.otf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.svg,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.ttf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.woff,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\icons.woff2
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.eot
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.eot
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.otf
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.otf
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.svg
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.svg
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.ttf
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.ttf
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff2
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/icons.woff2
Writing C:\myapps\node_modules\mytheme\themes\**\icons.*

/** SECOND mem-fs-editor/lib/action/copy.js outline-icons.* to anotherFolder\web\ **/
DISKFILES: C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.eot,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.svg,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.ttf,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff,C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff2
STOREFILES: C:\myapps\node_modules\mytheme\themes\**\outline-icons.*,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.eot,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.svg,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.ttf,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.woff,C:\myapps\node_modules\mytheme\themes\default\assets\fonts\outline-icons.woff2
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.eot
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.eot
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.svg
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.svg
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.ttf
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.ttf
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff
Writing C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff2
Written C:/myapps/node_modules/mytheme/themes/default/assets/fonts/outline-icons.woff2
Writing C:\myapps\node_modules\mytheme\themes\**\outline-icons.*
AssertionError [ERR_ASSERTION]: Trying to copy from a source that does not exist: C:\myapps\node_modules\mytheme\themes\**\icons.*
    at EditionInterface.exports._copySingle (C:\myapps\node_modules\generator-custom\node_modules\mem-fs-editor\lib\actions\copy.js:61:3)
    at files.forEach.file (C:\myapps\node_modules\generator-custom\node_modules\mem-fs-editor\lib\actions\copy.js:54:10)
    at Array.forEach (<anonymous>)
    at EditionInterface.exports.copy (C:\myapps\node_modules\generator-custom\node_modules\mem-fs-editor\lib\actions\copy.js:53:9)
    at Promise (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:18:15)
    at new Promise (<anonymous>)
    at module.exports._copyThemeAsset (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:17:12)
    at module.exports.fileTypes.forEach (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:46:20)
    at Array.forEach (<anonymous>)
    at module.exports.copyToOsgi (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:45:17)
AssertionError [ERR_ASSERTION]: Trying to copy from a source that does not exist: C:\myapps\node_modules\mytheme\themes\**\outline-icons.*
    at EditionInterface.exports._copySingle (C:\myapps\node_modules\generator-custom\node_modules\mem-fs-editor\lib\actions\copy.js:61:3)
    at files.forEach.file (C:\myapps\node_modules\generator-custom\node_modules\mem-fs-editor\lib\actions\copy.js:54:10)
    at Array.forEach (<anonymous>)
    at EditionInterface.exports.copy (C:\myapps\node_modules\generator-custom\node_modules\mem-fs-editor\lib\actions\copy.js:53:9)
    at Promise (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:18:15)
    at new Promise (<anonymous>)
    at module.exports._copyThemeAsset (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:17:12)
    at module.exports.fileTypes.forEach (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:46:20)
    at Array.forEach (<anonymous>)
    at module.exports.copyToOsgi (C:\myapps\node_modules\generator-custom\generators\doSomething\index.js:45:17)
icons module done
outline-icons module done
identical dist\themes\default\assets\fonts\icons.eot
identical dist\themes\default\assets\fonts\icons.otf
identical dist\themes\default\assets\fonts\icons.svg
identical dist\themes\default\assets\fonts\icons.ttf
identical dist\themes\default\assets\fonts\icons.woff
identical dist\themes\default\assets\fonts\icons.woff2
identical dist\themes\default\assets\fonts\outline-icons.eot
identical dist\themes\default\assets\fonts\outline-icons.svg
identical dist\themes\default\assets\fonts\outline-icons.ttf
identical dist\themes\default\assets\fonts\outline-icons.woff
identical dist\themes\default\assets\fonts\outline-icons.woff2
identical anotherFolder\web\default\assets\fonts\icons.eot
identical anotherFolder\web\default\assets\fonts\icons.otf
identical anotherFolder\web\default\assets\fonts\icons.svg
identical anotherFolder\web\default\assets\fonts\icons.ttf
identical anotherFolder\web\default\assets\fonts\icons.woff
identical anotherFolder\web\default\assets\fonts\icons.woff2
identical anotherFolder\web\default\assets\fonts\outline-icons.eot
identical anotherFolder\web\default\assets\fonts\outline-icons.svg
identical anotherFolder\web\default\assets\fonts\outline-icons.ttf
identical anotherFolder\web\default\assets\fonts\outline-icons.woff
identical anotherFolder\web\default\assets\fonts\outline-icons.woff2

Who is putting that glob pattern into the store? I tried to put debug points onto the mem-fs store to check but it's not there so i'm suspecting someone is manually placing it into the store ?

@SBoudrias
Copy link
Member

Sounds like a bug in https://github.com/SBoudrias/mem-fs-editor

Would you want to send a PR? I'll help review and merge it.

@alqh
Copy link
Author

alqh commented May 28, 2019

@SBoudrias I can't seem to figure out where or who is putting that glob pattern into the store? Do you have any ideas? I check all store calls within mem-fs-editor and it's not there. I even put loggings onto mem-fs and it's not there. I'm now thinking this is yeoman-generator because yeoman has it's own wrapper of store which it also adds the C:\myapps\bower.json,C:\myapps\package.json,C:\myapps\.yo-rc.json stuff

@alqh
Copy link
Author

alqh commented May 28, 2019

Alternatively, the match within mem-fs-editor's copy will need to ignore glob

@SBoudrias
Copy link
Member

Fix is released 👍

@alqh
Copy link
Author

alqh commented May 28, 2019

Thanks @SBoudrias ... Just on a side note, do you have any idea who put the glob path into the store? I have traced the write and I feel it's yeoman, but I don't know where it get intercepted.

@SBoudrias
Copy link
Member

As far as I know, only mem-fs-editor edit the store.

That being said, if you're using generator composition (composeWith), it's possible an old generators with an old version of mem-fs-editor is causing side effects due to a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants