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

Copying same glob path twice fails as glob path is in store and attempt to copy glob path #132

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

Comments

@alqh
Copy link
Contributor

alqh commented May 28, 2019

Hi,

This issue was cloned from yeoman-generator yeoman/generator#1110.
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 ?

@alqh
Copy link
Contributor Author

alqh commented May 28, 2019

Hey, wanna open a PR for this but don't think I have permission to push a branch. Whats your contributing policy?

@SBoudrias
Copy link
Owner

Hey, you need to click the clone button and create a branch on your fork.

From there, you'll then be able to open a PR. Let me know if you need more help to get this working :)

@alqh
Copy link
Contributor Author

alqh commented May 28, 2019

Opened PR #133

By the way, any chance we can please get a version with this patch? and how does it feed into yeoman's dependencies? Not really wanting to do a manual patch myself or workaround in my generator if possible :S

Thanks!

SBoudrias pushed a commit that referenced this issue May 28, 2019
…o do copySingle with the glob path as the glob path is currently in store. (#132) (#133)
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