Add dotfiles to user directory#213
Add dotfiles to user directory#213hectron wants to merge 2 commits intoAlex-Rose:masterfrom hectron:feature/dotfile-settings
Conversation
This commit adds the dotfiles to the user's home directory. It also renames the dotfiles to `.fbmessenger.enc` and `.fbmessengerrc`, to help distinguish what the files are actually consumed by.
| messenger.getFriends((_, friends) => { | ||
| const myself = friends[json.c_user]; | ||
|
|
||
| messenger.getMessagesGraphQl(myself.vanity, myself.id, 10, (_err, messages) => { |
There was a problem hiding this comment.
I changed this test to use getMessagesGraphQL, since I could not retrieve any messages using getMessages anymore.
|
|
||
| messenger.getFriends((_, friends) => { | ||
| const myself = friends[json.c_user]; | ||
| messenger.sendMessage(myself.vanity, myself.id, 'Running tests - Send message', done); |
|
|
||
| describe('Crypt', () => { | ||
| it('getInstance() should create a new singleton object', () => { | ||
| const crypt = Crypt.getInstance(); |
There was a problem hiding this comment.
I had an issue using getInstance, so instead this PR monkey patches Crypt's filename and filepath for testing.
It creates a .test.fbmessenger.enc file in the lib/test directory.
|
|
||
| after(() => { | ||
| Crypt.filename = oldCryptFilename; | ||
| Crypt.filepath = oldCryptFilepath; |
There was a problem hiding this comment.
We restore Crypt back to it's original state.
| const os = require('os'); | ||
| const path = require('path'); | ||
|
|
||
| const normalizeFilePath = filePath => { |
There was a problem hiding this comment.
This expands the home directory if it contains a tilde.
This is copied from the untildify javascript library.
| }; | ||
|
|
||
| const getDataDirectory = () => { | ||
| const environmentDataDirectory = process.env.FB_MESSENGER_DATA_DIR; |
There was a problem hiding this comment.
This allows the user to specify a custom location for their dotfiles.
|
I like the direction you're taking this, but just a few questions.
|
|
Thanks for the follow up, @p1ho! I appreciate you taking the time to ask questions.
|
|
Thanks for answering! I'd say everyone has their own habits, so I won't be too opinionated on this. On Windows, while it's not standard behavior to remove previous configuration, uninstallers usually prompt users whether they want to do that on uninstall (it'd be like a checkbox in the GUI). |
| const homeDirectory = os.homedir(); | ||
|
|
||
| if (homeDirectory) { | ||
| return filePath.replace(/^~(?=$|\/|\\)/, homeDirectory); |
There was a problem hiding this comment.
Is there a path helper that sanitize strings instead of a regex? I always prefer platform agnostic helper/libs for those sort of things
|
Hi @hectron I'm going to try your PR especially to see how it works out on Windows. Sorry for the late response, as you can imagine we're pretty busy with work and all... Thanks for your contribution! |
|
@Alex-Rose , I think there's a bug where if you log in for the first time in a while, it does a different flow than when you've already been signed in, which results in an infinite loop. I've had success by closing the app and trying again. However, the last few times my account has been flagged by Facebook as fraudulent, so I haven't tried to use the app too much to diagnose. |
I can confirm this happened on my machine as well. |

Problem
Whenever a user has to wipe out their
.kryptoniteor.settings, they have to navigate to whereverfb-messenger-cliis installed. In addition, the file names.kryptoniteand.settingsdo not make much sense if they are found elsewhere.Proposal
This pull request:
.kyptoniteto.fbmessenger.encand.settingsto.fbmessengerrcFB_MESSENGER_DATA_DIRenvironment variable is set toIn addition to this, it fixes the regression tests, so that whenever they are run, a users' settings are not altered. The tests also now won't ping @Alex-Rose directly. 😉