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

Support for templates in destination paths is using characters reserved on Windows. #115

Closed
jakub300 opened this issue May 13, 2018 · 9 comments

Comments

@jakub300
Copy link
Contributor

Recently added support for templates in destination paths (2bb43b7, #106) is using < and > that are reserved characters on Windows. Because of that is it currently impossible to checkout master and any project/generator that would use this would break.

@SBoudrias
Copy link
Owner

But we do replace these characters before trying to touch the file system. Can you explain more in which way this is breaking in your case? < and > are not reserved characters in JS strings.

@jakub300
Copy link
Contributor Author

In case of repository there is nested-<%= tag %>-package directory in tests. It is making impossible to checkout repository. I will show exact error when I get back home.

In real use (like yeoman generator) my understanding is that templates would be part of folder and file names inside of the generator so they have to be written to file system when generator is installed and later they would be replaced when generating project.

@SBoudrias
Copy link
Owner

Oh my bad, I totally missed that... We shouldn't have a folder with < in the path name.

The template should only be applied when creating a dynamic destination. It shouldn't be in the actual path source.

@LarsOL
Copy link

LarsOL commented May 28, 2018

Now that directory variables have been removed. How do we implement this? I am using yeoman which uses this library, and want to template the package (directory) names.

Are there any examples?

@asmagin
Copy link

asmagin commented May 28, 2018

I've created PR #117, that introduce processPath function. It works similar to process but applied to a file path.
It allows you to inject custom processing based on templating engine or regex.

@SBoudrias
Copy link
Owner

The feature is still working fine, we just changed the test files.

The idea is that you don't want to literally have the template inside of the file system. You just use the template literals inside you paths. copy('/<%= type %>/file.txt', '<%= type %>/dest-file.txt')

@LarsOL
Copy link

LarsOL commented May 29, 2018

Sorry I should have specified, I am using the glob syntax '**' to recursively copy everything from a template directory. It would be nice to have some way express varibles in the folder and file names?
Example of a apecific path within the template directory: <%= moduleName %>/<%= moduleName >Handler.js

Obviously, the token match should be changed to something that is windows compatible if possible.

@paztis
Copy link

paztis commented Oct 17, 2018

Hi,

I'm in the same case. Can you reopen the issue ?
In my case, I've a static template folder structure:
rootFolder/
<%=VAR1%>subfolder/
file.js

This is commited on git, and process further with copyTpl with globOptions: {dot: true}
Ths only problem is I cannot use these files on windows because of special chars < and >

To resolve this, we need

  • to be able to customise the template format { and } instead of < and > for exmaple
  • or to have access to the pathProcess function. Code seems to be ready but it's in still not published on npm since 5 months.

Can you look at it ?

Thanks

@st7art22
Copy link

Hello from 2023!
The answer to this problem is in the 4th parameter
Change file and folder names from <%= name %> to {#= name #}
For example like this

this.fs.copyTpl(
  this.templatePath(),
  this.destinationPath(),
  {
    name: this.props.name,
  },
  {
    name: this.props.name,
    delimiter: "#",
    openDelimiter: "{",
    closeDelimiter: "}"
  }
);

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

6 participants