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

Nest CLI Assets Property Fails to Copy Files on Windows Due to Path Format #2397

Closed
2 of 4 tasks
eranbetzalel opened this issue Nov 23, 2023 · 10 comments
Closed
2 of 4 tasks

Comments

@eranbetzalel
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When using the assets property in nest-cli.json, the file copying returns 0 files on Windows. This seems to be caused by path.join converting paths to Windows-style backslashes, which the glob package does not recognize.

I've debugged the code and saw this specific behavior in the copyAssets function.

{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "deleteOutDir": true,
    "assets": ["**/assets/*.html"]
  }
}

Minimum reproduction code

Not available, issue observable in the behavior of nest-cli

Steps to reproduce

Define assets in nest-cli.json using glob patterns.
Run a build or start command that triggers assets copying.
Observe that no files are copied.

Expected behavior

The assets defined in nest-cli.json should be correctly copied regardless of the OS path style.

Package version

10.2.1

NestJS version

10.2.8

Node.js version

18.17.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@micalevisk
Copy link
Member

please share the output of npx nest info

@eranbetzalel
Copy link
Author

[System Information]
OS Version     : Windows 10
NodeJS Version : v18.15.0
NPM Version    : 9.5.0     
                           
[Nest CLI]                 
Nest CLI Version : 10.2.1  
                           
[Nest Platform Information]
platform-express version : 10.2.10
cache-manager version    : 2.1.1  
event-emitter version    : 2.0.3
microservices version    : 10.2.10
mapped-types version     : 2.0.4
schematics version       : 10.0.3
passport version         : 10.0.2
terminus version         : 10.1.1
mongoose version         : 10.0.1
common version           : 10.2.10
config version           : 3.1.1
core version             : 10.2.10
jwt version              : 10.2.0
cli version              : 10.2.1
 version                 : 4.0.1
 version                 : 3.1.1
 version                 : 3.0.1

@eranbetzalel
Copy link
Author

This is a valid workaround for the development environment.

Adding "watchAssets": true seems to make it work correctly.

{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "deleteOutDir": true,
    "assets": [
      {
        "include": "**/assets/*.html",
        "watchAssets": true
      }
    ]
  }
}

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue? 🙏

@eranbetzalel
Copy link
Author

@kamilmysliwiec, Sure, I can do that.

@kasium
Copy link

kasium commented Feb 12, 2024

@eranbetzalel had you time to create a PR? This is quite bad issue for me

@CustomEntity
Copy link
Contributor

@kamilmysliwiec Is this a good "first issue"? I'd like to create a PR to fix this

@kamilmysliwiec
Copy link
Member

Feel free to do so @CustomEntity

@CustomEntity CustomEntity mentioned this issue Mar 24, 2024
3 tasks
@kamilmysliwiec
Copy link
Member

Fixed in 10.4.0

@eranbetzalel
Copy link
Author

Thank you @CustomEntity.

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

No branches or pull requests

5 participants