Usage of files nested in directories in filesToRemove cause issue when installing a file to the same directory
Environment
Output from ember version --verbose && npm --version && yarn --version:
ember-cli: 2.13.3
http_parser: 2.7.0
node: 6.11.0
v8: 5.1.281.102
uv: 1.11.0
zlib: 1.2.11
ares: 1.10.1-DEV
icu: 58.2
modules: 48
openssl: 1.0.2k
os: linux x64
3.6.0
1.2.1
Steps
- generate new addon
ember addon some-addon - generate new application
ember new some-app -
cd some-addon -
ember generate blueprint some-blueprint -
vim blueprints/some-blueprint/index.jswith content
/* eslint-env node */
module.exports = {
filesToRemove: ['app/styles/app.css']
};
-
mkdir -p blueprints/some-blueprint/files/app/styles && touch blueprints/some-blueprint/files/app/styles/app.scss -
cd ../some-app -
ember install <path-to-some-addon> -
ember generate some-blueprint entity-name
Actual result
installing some-blueprint
create app/styles/app.scss
remove app/styles/app.css
ENOENT: no such file or directory, open '/home/jprokop/work/sandbox/some-app/app/styles/app.scss'
Error: ENOENT: no such file or directory, open '/home/jprokop/work/sandbox/some-app/app/styles/app.scss'
at Error (native)
Expected result
I would expect that this use-case is possible to perform. While debugging this issue I noticed that ember-cli uses fs-extra which is probably the root cause of the issue. Looks like "race-condition" because calls are async.
Are you sure it's not your blueprint code that creates app.scss expected the "styles" folder to exist?
The result of the blueprint should be to "replace" default app.css with app.scss. If I just include files/app/styles/app.scss it works fine because there is already app.css in the same folder. Problem is that when you want to delete the app.css file by usage of filesToRemove it will also remove the folders on the path if they are empty. But according to this line and documentation of fs-extra.outputFile the outputFile method should create the parent directory if it doesn't exist. But in this case it will fail.
Ah I understand now. You weren't manually creating the file via fs.writeFile, but by placing the file in the blueprint, ember-cli was trying to create it for you, but it already conveniently removed the folder for you. This is definitely a bug. I don't have an estimate when it will be fixed, but if you could submit a failing test all the existing tests for the filesToRemove feature, that would expedite it. And of course, if you have to time to submit the fix as well, that would be greatly appreciated.
Closing as stale since I couldn't find a PR for a failing test.