-
Notifications
You must be signed in to change notification settings - Fork 215
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
Add overwrite protection to parent directory #358
Add overwrite protection to parent directory #358
Conversation
hmm, tests failing but not locally |
00a816e
to
50db293
Compare
@rwjblue do you know of any reason to allow |
test/cli_test.js
Outdated
@@ -36,6 +36,9 @@ describe('cli', function() { | |||
}); | |||
|
|||
describe('build', function() { | |||
beforeEach(function() { | |||
rimraf.sync('dist'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should generally not have to cleanup both before and after like this. Having to cleanup before generally indicates some other test is leaving us in an invalid starting state...
I think I found the problem. |
lib/cli.js
Outdated
); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
function isParentDirectory(outputPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can use findup-sync
to detect project root by locating package.json
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will check
c4cfc14
to
6c181bf
Compare
b8d799e
to
80efdec
Compare
function guardOutputDir(outputDir, removeExisting) { | ||
if (fs.existsSync(outputDir)) { | ||
if (removeExisting) { | ||
rimraf.sync(outputDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing rimraf as broccoli already handles doing a diff of the output directory and the new files to be added/removed, so rimraf actually makes it less efficient. https://github.com/broccolijs/broccoli/blob/master/lib/cli.js#L104
Good work, thank you!! |
This PR ensures that if using the
--overwrite
option andtarget
is a parent directory of the project, the process will exit(1).This is inline with ember-cli.
Also adds some more tests for
--overwrite
option.Question, why do we even allow the
target
directory to be a literal parent of the project, I don't really see why you would want that?