Posts

Showing posts from January, 2019

Lab2, Git Commands

Image
"git reset" command  git reset command is used for undoing different types of changes. Using it we can either discard commits in our private branch or throw away uncommitted changes. You can pass different parameters to your reset command in order to determine the command's scope. git reset command has 3 different modes: --soft  The staged snapshot and working directory aren't changed. --mixed (default) The staged snapshot is updated to match your commit, the working directory isn't affected. --hard  The staged snapshot and working directory are both affected. The most frequently used but at the same time the most dangerous option. It completely erases things you no longer want to have. Removing your last commit example For example, we committed some changes to our file, but made a mistake and want to revert those changes. One of the ways to do that is to use"reset". git reset HEAD~1 command will throw away the latest com

Filer Project, Release 0.1

Image
The main purpose of Release 0.1 was to get familiar working with GitHub and using Git commands. We were contributing to the Filer web filesystem project refactoring the code to use "let" or "const" instead of "var" for creating variables and constants.  Both "let" and "const" are block-scoped and preferred over "var". The only difference between them is that "const" values can't be reassigned. So unless your variable is going to change you should always use const.  Strict Mode in JavaScript In order to activate strict mode you should add "use strict" directive on top of your code. The benefits of this mode are the following: eliminates some silent errors (throws errors instead) helps to write a secure JS code disables confusing features  Not Allowed in Strict Mode Use undeclared variables/objects Delete a variable/function Duplicate a parameter name Octal numeric literals Read-only/

fs.rmdir() vs fs.rmdirSync() in Node.js

The main purpose of rmdir() and rmdirSync() methods in the fs module is to remove a directory. If you are going to use any of these two methods, you should also remember that using them it is only possible to remove an empty directory. In case your goal is to get rid of the folder which contains another files or directories you would need to install the additional fs-extra module that would add more features on top of the fs. You can use remove() method from the fs-extra module to delete directories that contain something. fs.rmdir(path, callback) Removes a directory asynchronously. If the directory isn’t empty the function will throw an exception. Passed Parameters: path – string, path to the directory which you want to remove. The function won’t work if you will pass a path to the file instead of the directory (will result in ENOENT error on Windows and an ENOTDIR error on POSIX) callback – function, returns an error. Source code:  function rmdir(path, callback