Release 0.1

For the first release we were given the option to either find a bug or implement the du shell command in Filer. The follow post is a summary of what I learned.

I choose to implement the du command and here is my pull request.

Setting the dev environment

The first step was reading the CONTRIBUTE.md file in GitHub and then forking the project. After forking, a copy was cloned onto my local machine.

git clone [email protected]:liandrew/filer.git

To run the tests, grunt was installed using NPM

npm install -g grunt-cli

After installing grunt ensure dependencies for the project are installed. I forgot to do this so I couldn’t run grunt test.

npm install

Run the tests with

grunt test

After passing all tests I was ready find out more about the du command.

Understanding the bug

In the past I’ve used du to find an estimate of how much space a folder was occupying and for doing quick sanity checks. After reading more on du I found that I had to get the follow to work:

1. return sum total of all sizes for all files in directory recursively
2. return depth-first list of all entries in the directory followed by the directory itself

Using 1 and 2 as test cases sounded right so I programmed what I thought I should see. At first it seemed really strange to write the test cases first but doing it first actually makes sense - it helps with understanding the problem.

Using the specs outlined in Implement du shell command #277 as a guide, I copied the ls command since it’s similar and started to fiddle with it to learn. Putting callbacks and closures into practice took a bit of getting use to. It was hard to follow what was going on in ls since I didn’t have a good understanding of the callback pattern. So I backtracked, went to the web and read a few helpful blog posts on callbacks and then practiced writing a few examples of my own. Other questions that popped up after looking at the ls code:

Using Git is Awesome

Using Git I was able to easily go back and forth between branches and revert code on the fly. I found these commands useful:

Create a new branch from a previous commit

git branch <branch name> <hash>

When things go bad I found this useful for going back to a clean copy of the last commit

git checkout .

Conclusion

I’ve learned a lot through the process of getting from setting up a dev environment to implementing code. Test #2 failed, I was able to return the list in depth-first order but had trouble adding the current path to the end without messing up the callback. I will try to revisit this and reach out to the community and fellow students for help. I definitely need more practice with callbacks and closures. For the next release, I will try to reach out to the community more often, be active on irc to try to help and get help from the community.