We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Copy Assets Handler ignore glob doesn't work on Windows due to path.join changing glob forward slashes to backslashes.
Let's suppose I have the following three files in my src folder:
And I would want to copy only the assets.json to my target folder.
Now using the configuration produces the expected result on OS'ses using forward slash, but not on Windows as it uses backslash.
"build": { "executor": "@nx/js:tsc", "options": { // shortened... "assets": [ { "input": "./src", "glob": "**/*", "output": "./src", "ignore": ['**/*.ts'] } ] } }
On Windows the ignore glob is turned into src\\**\\*.ts which doesn't match any of the files and thus all files are copied over.
src\\**\\*.ts
Only assets.json should be copied over as index.ts and index.test.ts should match the ignore glob.
No response
Node : 20.12.1 OS : win32-x64 npm : 10.5.0 nx : 18.3.4 @nx/js : 18.3.4 @nx/jest : 18.3.4 @nx/linter : 18.3.4 @nx/eslint : 18.3.4 @nx/workspace : 18.3.4 @nx/devkit : 18.3.4 @nrwl/tao : 18.3.4 typescript : 5.4.3 --------------------------------------- Registered Plugins: @nx/eslint/plugin @nx/jest/plugin
Copy Assets Handler uses minimatch here:
nx/packages/js/src/utils/assets/copy-assets-handler.ts
Line 162 in f74aeab
And here:
Line 184 in f74aeab
Minimatch instructs to use only forward slashes on Windows as I have done: https://github.com/isaacs/minimatch/blob/main/README.md#windows
But the problem seems to be here where the glob is joined with input path:
Line 92 in f74aeab
Changing that to this should fix the issue:
// minimatch only supports Unix paths if (f.ignore) ignore = f.ignore.map((ig) => path.join(f.input, ig).replace(/\\/g, '/'));
The text was updated successfully, but these errors were encountered:
AgentEnder
Successfully merging a pull request may close this issue.
Current Behavior
Copy Assets Handler ignore glob doesn't work on Windows due to path.join changing glob forward slashes to backslashes.
Let's suppose I have the following three files in my src folder:
And I would want to copy only the assets.json to my target folder.
Now using the configuration produces the expected result on OS'ses using forward slash, but not on Windows as it uses backslash.
On Windows the ignore glob is turned into
src\\**\\*.ts
which doesn't match any of the files and thus all files are copied over.Expected Behavior
Only assets.json should be copied over as index.ts and index.test.ts should match the ignore glob.
GitHub Repo
No response
Steps to Reproduce
Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
Copy Assets Handler uses minimatch here:
nx/packages/js/src/utils/assets/copy-assets-handler.ts
Line 162 in f74aeab
And here:
nx/packages/js/src/utils/assets/copy-assets-handler.ts
Line 184 in f74aeab
Minimatch instructs to use only forward slashes on Windows as I have done:
https://github.com/isaacs/minimatch/blob/main/README.md#windows
But the problem seems to be here where the glob is joined with input path:
nx/packages/js/src/utils/assets/copy-assets-handler.ts
Line 92 in f74aeab
Changing that to this should fix the issue:
The text was updated successfully, but these errors were encountered: