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

Add edit capability to ember init #1000

Merged
merged 4 commits into from
Jun 13, 2014
Merged

Conversation

rondale-sc
Copy link
Contributor

This has been added to edit-file-diff model in order to more easily abstract when ember update is a thing

When you run ember init a new option is given when the process encounters a file it needs input from user. If you select it the following events take place:

  1. A tmp file containing the .diff of your file as compared to the
    blueprint file
  2. A child process is spawned with whatever command is set to $EDITOR
    with an argument of the above tmp file path
  3. On the 'close' event of this child process the diff you've edited is
    applied to your file
  4. the tmp file from step 1 is removed
  5. normal process resumes

@rondale-sc
Copy link
Contributor Author

Added a little video describing the use case:

https://www.dropbox.com/s/inarmwkye7wpjln/final-ember-cli-edit-file.mov

@@ -35,6 +36,10 @@ FileInfo.prototype.confirmOverwrite = function(path) {
]
};

if(! /^win/.test(process.platform)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was just going to ask about this^ Can I assume you tested that this PR doesn't break our windows support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option to start the edit process shouldn't be available in non windows environments. But I need to check. I'll spin up an AWS instance tonight to verify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefanpenner I ran on Windows, it correctly prevents showing of the prompt (windows 7). And didn't blow up. :) (though I should mention that this was a quick check)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like due diligence has been exercised.

@jgwhite
Copy link
Contributor

jgwhite commented Jun 12, 2014

This is awesome 😄

* This has been added to edit-file-diff model in order to more easily
* abstract when `ember update` is a thing

When you run `ember init` a new option is given.  If you select it the
following events take place:

1. A tmp file containing the .diff of your file as compared to the
blueprint file
2. A child process is spawned with whatever command is set to $EDITOR
with an argument of the above tmp file path
3. On the 'close' event of this child process the diff you've edited is
applied to your file
4. the tmp file from step 1 is removed
5. normal process resumes
This is for editors like sublime and text mate that will by default
launch and resume execution of io.  In these cases it is usually
reccomended to use the `-w` flag and to set those flags on the $EDITOR
variable in your rc file.

e.g

$EDITOR=mate becomes $EDITOR='/usr/local/bin/mate -w'

This updates the childProcess spawn to trim arguments and pass them as
appropriate.

In the case of mate -w

editor is set to `mate`
editorArgs is set to ['-w']
@stefanpenner
Copy link
Contributor

LGTM

changelog entry and we are good to go

@rondale-sc
Copy link
Contributor Author

Need to add error handling for when a patch can't be cleanly applied.

Which begs the question, what should we do if a patch is not cleanly applicable? Prompt the user again?

/cc @stefanpenner

@rondale-sc
Copy link
Contributor Author

@stefanpenner This has been resolved. It now re-requests confirmation if diff is not applicable. 😄

rwjblue added a commit that referenced this pull request Jun 13, 2014
Add edit capability to `ember init`
@rwjblue rwjblue merged commit 4961cff into ember-cli:master Jun 13, 2014
@stefanpenner
Copy link
Contributor

👍

@rondale-sc rondale-sc deleted the ember_init_edit branch June 13, 2014 12:51
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

Successfully merging this pull request may close these issues.

4 participants